Friday, 17 April 2015

Pointers to Object Members (Data Members)


Whenever an object is created, memory is allocated to it. The data defining the object is held in the space allocated to it, i.e., the data and member functions of the object reside at specific memory locations subsequent to the creation of the object.

The pointer to an object member can be obtained by applying the address of operator & to a fully qualified class member-name.


Members of a class can be accessed using either pointer to an object, or pointer to members itself. A pointer to a class members is declared using the operator ::* with the class name. The syntax for defining the pointer to class members is


Data_type Class_name :: * Pointer_name

Pointer_name = &Class_name :: Member_name




No comments:

Post a Comment