1. Composition of classes: Data and functions
Public: can be accessed by an object of the class outside the class
Private: Accessible only by member functions within a class
Protected: Can be accessed by a member function of this class, or by a member function of a derived class of this class
Access keyword: Private is the default keyword
!! It is not possible to assign an initial value to a data member in a class declaration, that is, to initialize it, and to assign an initial value to the data member only after the class's object definition
2. member functions
There are three member functions based on access rights, where private member functions can only be accessed by other member functions in this class, and public member functions may be accessed by objects of that class outside the class
In addition, it can be divided into ordinary member functions and inline member functions .
Inline member functions are also divided into implicit declarations and explicit declarations
This detail will not knock up, rectification 52 pages
3. Definition and use of objects
1. Defining objects directly
2. Define a pointer object that has no name, called a nameless object, but that object has an address that is stored in the pointer variable
4. Class scope and access properties for classes
Object Assignment Statement , the assignment between C + + two objects of the same type is implemented by overloading the operator
Simply assign a value to the data member in the object and not assign a value to the member function
Assigning a value using = when there is a pointer in the class can produce an error
5. Constructors
Function: Because the class itself does not allow assignment initialization at the time of definition, it produces a function that is specifically used to initialize the assignment, the constructor
Characteristics:
1. No return value
2. Same name as Class
3. Allow custom parameters
4. Special member functions
5. Automatically execute when an object is created
6. Initialize the member list (depending on the constructor)
Primarily used to initialize a type member that is not allowed to be assigned with an assignment statement
For example, a data member that references and the const modifier decorates
7. Constructors with default parameters
Balabala no need to explain.
The second leading edge of C + + (ii)-Classes and objects (upper)