1. face important features of Objects
Encapsulation
Inheritance
Polymorphism
2. constructor and sufficient analysis functions
■ Constructor and destructor are implicitly called by the program and cannot be displayed by the user.
■ Neither the constructor nor the Destructor returns a value.
■ Constructor and destructor cannot be inherited
■ Destructor can be virtual and constructor cannot
■ It is best not to do anything other than assigning an initial value to the constructor.
3. default parameter problems
In C ++, you can define the default value for the parameter:
Class person
{
... ...
PRIVATE:
Float m_weight;
... ...
Void setweight (float Weight = 50 );
};
Void person: setweight (float weight)
{
M_weight = weight;
}
Call the following code:
Person you;
You. setweight ();
M_weight is set to 50 by default.
Note:
■ The default parameter value can only be given in the function prototype, and cannot be given again in the function definition.
■ A function may have many default parameters, but it must be placed continuously at the end of the function.
Error:
Void myfunc (int A = 1, B, c = 2 );
Void myfunc (int A = 1, C = 2, B );
Correct:
Void myfunc (int B, A = 1, C = 2 );