2.lab 2 - Classes Part 2
2.lab 2 - Classes Part 2
Experiment 2:
“Implement Classes & Objects using C++
Part II”
Members of a class
Data Members
Member functions
Constructors
Constructor Overloading
Destructors
Friend Function
Storage of Objects in Memory
Data members are stored separately for each object
Member functions are stored once, used by all objects
Each object of a class has separate memory for their data
members, However, the member functions of a class are stored
at one place and shared by all objects of that class
Example:
Constructors
A constructor is a member function of a class that is called and
executed automatically when an object of that class is created.
Name of constructor function is same as name of class itself.
A constructor function have many arguments but it can not
return any value.