- A class is a blueprint that doesn’t exists and works as template for objects.
- A class contains member data or member functions together.
- Generally class contains two concept :
- Class declaration
- Definition of functions
- A class uses keyword “class” before the class name and semicolon is used for terminating the declaration of class.
Access modifiers :
- Access modifiers provides security to the data members and member function of the class.
- It doesn’t allow them to move around.
- It decisides the visibility of data.
- Three keywords are used:
Member function of the class can be declared inside the class or outside the class.
- The declared willn’t work until its object is not created.
- A class works as blueprint or template for objects.
- A class decides the behavior of an object.
- More than one object of a same class can be created.and must be declared in main( ).
- Syntax :
A simple C++ program with class :