A class is a prototype that defines the abstract characteristics of an object, such as attributes, fields, or properties. It also defines the behaviors of objects, such as methods, operations, or its features. In other words, you can say that classes describe objects.
Classes provide modularity and structure in an object-oriented program. A class is a user-defined data type that may consist of data members and member functions. You can bind data representations and their algorithms into a new data type by defining a class. The syntax to use a class as a data type of an object in C++ is same as the syntax to use the data type of an integer.
For example, if Fruit is considered to be a class; mango can be one of the object of this class. The following code snippet shows the declaration of an object, mango, of the Fruit class:
Fruit mango; Similar to mango, other objects of the Fruit class can be apple, banana, and orange.
No comments:
Post a Comment