C + + Learning 8.1-Welcome to object-Oriented programming

Source: Internet
Author: User

C + + Learning series of articles are translated from learncpp.com, a very good C + + learning site, this site let me realize that the original profound truth can also be said so easy to understand, If all the software has a similar site that much good ah, in order to deepen the impression, I decided to translate the site by chapter, Hey, I do not believe I can do it ...

All the previous chapters have a common feature so far: they are all non-object oriented. Now that you have mastered some basic knowledge we can go into object-oriented programming, this is the play!

In traditional programming methods, a program is simply a series of instructions sent to a computer, by defining the data (through variables) and then processing the data (through statements and functions). The data and the functions that manipulate the data are completely independent entities that are combined to achieve the desired results.

So what is object-oriented programming? As in many other cases, it may be easier to understand through practical examples. Look around you-everything you see is the object. The object has two main components: 1) A series of attributes (e.g. weight, color, size, volume, shape, etc...) ), 2) They can show a number of behaviors (for example: being opened, heating other objects, etc...) )。 These properties and behaviors are non-separable.

In traditional programming, attributes (data) and behavior (functions) are separate entities, meaning that traditional programming often does not provide a visual representation of the real world. Proper control of the relationship between attributes and behavior becomes the responsibility of the programmer.

Object-oriented programming gives us the ability to define an "object" that ties properties and behaviors together into a self-contained, reusable package. This allows the program to write more modular, easier to write and understand, and to achieve a high degree of reuse. Objects also provide a more intuitive way to interact with our data by allowing us to define how we interact with objects and how that object interacts with other objects. Be aware that object-oriented programming does not replace traditional programming. More precisely, he adds a new tool in your programming toolbox to handle complex requirements when you need them.

Object-oriented programming also brings some other useful concepts: inheritance, encapsulation, abstraction, and polymorphism (the philosophy of a programming language designer is that it can be expressed with a profound vocabulary without the use of simple words). We'll cover these concepts in the next few chapters. There's a lot of new stuff going on, but once you've mastered object-oriented programming, you won't want to go back to the purely traditional way of programming.

C + + Learning 8.1-Welcome to object-Oriented programming

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.