If God is a programmer's C ++ Analysis

Source: Internet
Author: User
If God is a programmer's C ++ analysis-general Linux technology-Linux programming and kernel information, the following is a detailed description. If God is a programmer, we don't need to mention it. It must be everyone's instance. But does God define people as interfaces or classes?

Do we inherit the base class of people or implement human interfaces? How can this category be changed? How are twins generated? What about connected babies?

My opinion is:

People are classes, not interfaces. Some people are born, so people should be classes.

The demon belongs to the inheritance of protection, which hides some details and covers some functions. since it is protected inheritance, you cannot directly treat him/her as a person, but he/she may use some using commands internally to expose some methods and attributes inherited from humans, at the same time, because it is inheritance, he/she also covers several virtual functions to meet their own needs.

Another idea is that the human demon inherits from the human and the Demon class separately, but the inheritance must be protected. otherwise, you will be surprised by the easy transformation to the human pointer. in short, there are many views on the issue of the demon.

There is no difference between twins and other people. They are only produced in two ways at a time. Therefore, they are derived from the base class just like ordinary people. However, constructors are private, you must use a Factory. At the same time, the returned value is not a single person, but a std: pair.

Multiple births? Similarly, but this Factory may return a vector.

The connected baby belongs to a relatively advanced usage and adopts the virtual inheritance method, so it shares the same basic class.

So far, the base class has been declared in private, but the copy constructor and value assignment function have not been defined. Therefore, the object cannot be copied.

Someone tried to clone people by external means. Currently, the "C ++" Technology is not very good yet.

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.