this Pointer
On defining a class, the member functions are created and placed in the memory space only once i.e., only one copy of member functions are maintained, that is shared by all the objects of the class. Memory space for the data members is allocated separately for each object.

This has an associated problem. If only one instance of member functions exist, how does the compiler come to know which object's data member is to be manipulated?
For example, if member-function3 is capable of changing the value of data-member2 and the user wants to change the value of data-member2 of object1. How would the member-function3 come to know which object's data member is to be changed?
The answer to this problem is this pointer. When a member function is called, it is automatically passed with an implicit argument that is a pointer to the object that invoked the function. This pointer is called this. That is if object1 is invoking member-function3, then an implicit argument is passed to member-function3 that points to object1 i.e. this pointer now points to object1.
Example:
Example: A program to illustrate the working of this pointer.

- Virtual Functions
Dynamic polymorphism allows programmers to write code using functions applied to objects of the base class without worrying about how those functions will actually be defined by derived classes. For instance, programmers might call functions on a Shape object that computes its area or perimeter, without concerning themselves with the actual (derived) type of the [...]...
- Static Class Members
The members (data members and member functions) of a class may be qualified as static by preceding member declaration with the keyword static. There may be static data members and static member functions in a class. Static Data Member A static data member of a class is just like a global variable for its class. [...]...
- Classes
A class is an approach to bind the data, describing the entity or an object, and its associated functions together. In C++, a class creates a data-type that is used to create objects of that particular type. Class represents a group of similar objects. Example: class account { private: int accoutno; char type; float balance; [...]...
- Friend Function
The private data members of a class cannot be accessed by functions that are not a part of the class. The access to such members can only be given to the functions by specifying the function as friend of the class whose data structures are required by the function. In simple words, we can say [...]...
- Operator Overloading – Introduction
Operators like + (plus), – (minus), * (multiply), / (divide) work very well with data types such as int, float, etc. But when it comes to user defined data types these operators do not work on their own. To make them work, we need to define special functions that tell the operators how to handle [...]...




