A class specification just defines the properties of a class. To make use of a class specified, the variables of that class type have to be declared. The class variables are called object. Objects are also called as instance of class.
In the above statement s is an instance of the class student.
Objects can be created in two methods,
(1) Global object
(2) Local object
If an object is declared outside all the function bodies or by placing their names immediately after the closing brace of the class declaration then it is called as Global object. These objects can be used by any function in the program
If an object is declared with in a function then it is called local object.
It cannot be accessed from outside the function.
A global object can be declared only for global class. If a class definition is specified outside the body of all functions in a program then it is called global class
std class add //Global class
sum = a+b;
add a3; //Local object for a global class
a3.getdata(); //public data member accessed from outside the class