Unlike C AND Pascal, C++ provides an unambiguous mechanism to support the dissimilarity between specification and implementation. This explicit mechanism of C++ is known as Class. C++ class programmer to use class mechanism efficiently. There are four major components of C++ class that are mentioned below:
- Class name: Rectangle is an example of class name
- Data members: Data that make up the class (e.g. x l, y l, h, and w)
- Member functions: It can be defined as the set of operation that can be applied to the objects of a class (e.g. GetHeight(), GetWidth()).
- Level of program access: It controls the level of access to data members and member functions from program code. There are three significant levels of access to class members like private, protected and public. A public data member (member functions) can be accessed from anywhere in a C++ program. On the contrary, a private data member (member functions) can only be obtained within its data class or by a function "or!" Protected data member (member functions) can be viewed from within its class or subclasses.