Declare class and object
The class of C++ is called the core of C++. All behaviors of object is inside the class. Generally Object Oriented Programming is starting from the class. After making data type using class then we can define the object of that class type. For that reason we can say, class is a template of the object and object is a instance of class.
We can define class is a class keyword. The structure of class is define below :
class class_name // class keyword { private: // access specifier private_member_variables; private_member_function(); public: // access specifier public_member_variables; public_member_function(); protected: // access specifier protected_member_variables; protected_member_function(); }; // must be put semicolon end of class |
Object Declaration :
class_name object_name_1, object_name_2 , ---,object_name_n; |
* We can define object inside the main() function and other classes.
Example :
The output is :
Written by 'Shojib'
No comments:
Post a Comment