Classes and Objects
A class is a vehicle to execute the OOP features in the C++ language. Once a class is declared, an object of that type can be explained. An object is said to be a specific instance of a class just like Maruti car is an instance of a vehicle or pigeon is the instance of a bird. Once a class has been explained several objects of that type can be declared. For instance, an object of the class defined above can be declared with the following statement:
player Sachin, Dravid, Mohan ;
[Or]
class player Sachin , Dravid, Mohan ;
where Sachin and Dravid are two objects of the class player. Both the objects have their own set of member variables. Once the object is declared, its public members can be accessed using the dot operator with the name of the object. We can also use the variable no_player in the public section with a dot operator in functions other than the functions declared in the public section of the class.
e.g.
Sachin.getstats();
Dravid.showstats();
Mohan.no_player = 10;