C ++ is both an object-oriented and process-oriented language. Here is an important concept-class.
What is a class? Class is an abstraction of objects. For example, every real person is an object and has many common features (one head, two legs, walking, and running ), this person with common characteristics becomes a class. A class is an abstract term. Every person (I .e. an object) is an instance of this class.
The common characteristics of objects are the attributes and behaviors of objects. A video recorder is an object whose attributes are manufacturers, brands, weights, colors, and so on. Its behavior is its function, such as video recording, video recording, fast forward, and backward operations.
In the C ++ program, you must first define a class, such:
Class Name
{
Define variables;
....
Define functions
}
The member list in the class body, including data and operation data functions, that is, data members and member functions. This reflects the encapsulation of classes and the concealment of information.
Member functions are generally declared in the class body and defined in the class body.
Constructor: assign values to objects
Destructor: releases the space of the object member at the end of the function field.
Inline function: to save function call time
Complete various functions .......
To define an object, you need to instantiate the class. Shape: Class Name Object Name
A class is an abstraction that does not occupy any memory. It allocates space only when it is instantiated as an object.
Computers use objects to describe things in the world. Objects are connected by messages and functions are used to complete various functions.
In short, this is the object and class.