Classes are created using the keyword class. A class declaration defines a new type that links code and data. This new type is then used to declare objects of that class. Thus, a class is a logical abstraction, but an object has physical existence. In other words, an object is an instance of a class.
A class declaration is similar syntactically to a structure. Here, is the entire general form of a class declaration that does not inherit any other class.
Class class-name
{
private data and functions
access-specifier:
data and functions
access-specifier:
data and functions
.
.
.
access-specifier:
data and functions
}object-list;
The object-list is optional. If present, it declares objects of the class.
0 Comments