Class Objects:
An Object is an instance of a class. Creating an object of a class is like defining a variable of a data type. Once a class has been declared, we can create variables of that type by using the class name. Syntax for creating an object is
class_name object_name;
e.g.
The statement box b1 ; creates a variable b1 of type box. This variable b1 is known as object of the class box. Thus, class variables are known as objects. The objects can also be created when a class is defined by placing their names immediately after the closing braces like
class box
{ private:
……..
public:
……
}b1,b2,b3;
But, this technique is rarely used in practice.
No comments:
Post a Comment