Class specification: – A C++ provide support for defining classes, which is a significant feature that makes C++ and object oriented language in C term, a class is a natural evolution a structure. Classes contents not only data but also function. The function are called member function and define the set of operation that can be perform on the data member of a class. Thus a class can be described as a collection of data members and member function. This property of C++, which allow association of data and function into a single unit is called encapsulation. Sometimes, classes may not contain any data member and member function such classes are called empty class. The syntax of the class specification is-

                Class <class name>
                                Body of the class

The class specifies the type and scope of its members. The keyword class indicate that the name which fallows is an abstract data type. The body of a class contents data member and member function. Body of class enclosed which a curly brace terminated by semi colon sign.

Inside the body of a class, data members and member function can be divided in three section. Function of these three section are follows.

  1. Private: – The private section of class have strict axes control. Only the data members on member function of the same class can access these member and show that, these member are also called private member. Private member are inaccessible outside the class, thus, providing a mechanism for preventing accidental modification of data member and member function. A private section is accessible with or without its name. it is accessible the keyword private:
  2. Public: – The public section of class which are to be accessible outside the class, should be declared in the public section. All data members and member functions declare in the public section of the class can be access without any restriction from anywhere in the program, either by function that belonging to the class or by those external to the class. A public section can be declared with the keyword public: and it must be followed by private members.
  3. Protected section: – The access control of the member of protected section is similar to that of private members and has more significance in inheritance. The protected member declares before the public member and its keyword is protected: