C + + Focus with mind

Source: Internet
Author: User

1. In public Succession: (1). The derived class object stores the private members of the base class (2). A derived class object can use a method of the base class (3). A base class reference can reference a derived class object, and a derived class reference can not reference a base class object

2. When a base class reference refers to a derived class object: The function used by the Destructors class reference is a virtual function, then the function used is a derived class virtual function. The base class function is used when it is not a virtual function.

3. A function needs to behave differently in a derived class and must be declared as a virtual function (a virtual function declared by a base class, which is also a virtual function in a derived class, even if the virtual keyword is no longer used.) )

4. Pure virtual function means: I am an abstract class! Don't instantiate me! Pure virtual functions are used to standardize the behavior of derived classes, which are actually called "interfaces". It tells the user that my derived class will have this function.

5. Constructors cannot be virtual

6. A destructor for a base class must be virtual

C + + Focus with mind

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.