Password in C ++

Source: Internet
Author: User

What do you know about these passwords?

 

1. The constructor is designed to be protected, indicating that this class is used to help subclassConstruct the interface.

2. The constructor is designed to be private, indicating that this class is used to set static methods. You can use public static methods to create an object.

 

 

3. The Destructor is designed as a virtual function, indicating that the class can use its reference or pointer to manage the lifecycle of the subclass.

4. The Destructor is designed to be protected, indicating that the lifecycle of the class can only be managed by sub-classes.

5. The Destructor is designed to be private, indicating that this class is used to set static methods. You can use a public static method to destroy an object.

 

 

6. Protection inheritance means that child classes require the interfaces of the parent class to help implement the Child classes, and use the interfaces of the parent class to provide interfaces for the Child class (Generally, it is a virtual function.).

7. Private inheritance indicates that child classes need interfaces of the parent class to help implement the Child classes. The coupling between the two classes is very small, however, if the parent class has data members or virtual functions, the binary structure of the Child classes will be affected.

 

 

8. Hide the Public Non-virtual functions of the parent class, but the implementation of the subclass method calls the method with the same name as the parent class and ensures that the pre-and post-condition remains unchanged, indicates that the subclass is an extension of the parent class (is-).

9. Hide the Public Non-virtual functions of the parent class, but the implementation of the subclass method does not call the method of the same name as the parent class, indicating that the subclass is a deformation of the parent class.

 

 

10. Overwrite the virtual function of the parent class, but the implementation of the subclass method calls the method with the same name as the parent class and ensures that the pre-and post-condition remains unchanged, indicates that the Child class is a parent class's runtime upgrade (is-).

11. Overwrite the virtual function of the parent class, but the implementation of the subclass method does not call the Public/protection method of the parent class with the same name, indicating that the subclass is a parent classDeformation during operation (uncontrollable behavior, poor design).

 

 

12. The virtual function is designed to be protected, indicating that the internal implementation of this class can be deformed during runtime.

13. Virtual functions are designed to be private, indicating subclass of the class.The implementation details are irrelevant to the parent class. The parent class cannot make any assumptions and constraints on its implementation details. (To ensure secure behavior, the parent class and the Child class must be strongly coupled). A typical example is to return the class name.

14. Virtual functions are designed to be public, indicating that interfaces of this class can be stored inRuntime Deformation(Uncontrollable behavior, poor design).

 

 

15. Has a swap member function, indicating that the class (highly probable) uses the proxy mode to manage objects.

Related Article

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.