Describe how memory is allocated to objects of class with suitable diagram.
Description: The memory space for object is allocated when they are declared and not when the class is specified. Actually, the member functions are created and placed in memory space only once when they are defined as a part of a class definition. Since all the objects belonging to that class use the same member functions, no separate space is allocated for member functions. When the objects are created only space for member variable is allocated separately for each object. Separate memory locations for the objects are essential because the member variables will hold different data values for different objects this is shown in fig: