In Object-oriented programming (OOP), classes and objects have attributes. Attributes are data stored inside a class or instance and represent the state or quality of the class or instance. One can think of attributes as noun or adjective, while methods are the verb of the class.
Attributes - things that the object stores data in, generally variables.
Methods - Functions and Procedures attached to an Object and allowing the object to perform actions.
A class is defined in C++ using keyword class followed by the name of class. The body of class is defined inside the curly brackets and terminated by a semicolon at the end.
When a class is defined, only the specification for the object is defined; no memory or storage is allocated. To use the data and access functions defined in the class, objects are required to create.
The public data members are also accessed in the same way given however the private data members are not allowed to be accessed directly by the object.
Accessing a data member depends solely on the access control of that data member.
This access control is given by Access modifiers in C++.
Using the using keyword, it means read things by default.
Say: If there is an object name that doesn't exist in current namespace, then check if there exists a namespace std in which it does exist, and use that object.
Thus, it doesn't really add a function, it is the include that "loads" cout, cin, endl and all the like.
Write a program to create a Number class contain two integer number A and B and using Natural Number object read its value, do its sum and display its value and their sum.
C++ is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify.
C++ provides the feature of pointers. We can directly interact with the memory by using the pointers. We can use pointers for memory, structures, functions, array etc.
C++ introduces a new kind of variables know as the reference variable.
A reference variable provides an alias (alternative name) for a previously defined variable.
For Example:
A public member function can also be defined outside of the class with a special type of operator known as Scope Resolution Operator (SRO); SRO represents by :: (double colon)