Note 1: a little bit

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.