Reading Notes Objective c ++ Item 32 ensure that the "is-a" model is created based on the public inheritance, and the specified tiveis-1. What is the "is-a" relation inherited by public?
The most important criterion in the C ++ object-oriented
1. What is the "is-a" relationship of public inheritanceThe most important criterion in C + + object-oriented guidelines is that public inheritance means "is-a". Remember this rule.If you implement a Class D (derived) public that inherits from Class
Common inheritance (public) inheritance, private inheritance, and protection Inheritance (protected) are the three commonly used methods of inheritance.1. Public inheritancePublic inheritance is characterized by the public and protected members of
Item 32: Make sure public inheritance simulates "is-"
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
InSome must watch while some must sleep(W. H. Freeman and Company, 1974) in this book,
1. Public inheritance)Public inheritance is characterized by the original state of both the public members of the base class and the protected members as the members of the derived class, while the private members of the base class are still private.
1. Public inheritance
Public inheritance is characterized by the public and protected members of the base class as members of derived classes, all of which remain in their original state, while private members of the base class remain private.
2.
First, the article for the reasonSimple and clear reasons, commonplace but not really solve the problem, want to understand this problem.Ii. a lengthy definitionLet's take a look at these lengthy definitions:Public inheritance:
When a class
Public inheritance, private inheritance, and protection inheritance in C ++I. Reasons for the article
The simple and clear reason is a common problem that has not been solved. I want to clarify this problem.Ii. Lengthy Definition
Let's take a look
1 The visibility of the base class member to the derived class
1. Communal inheritance (public): When a public member of a base class and a protected member are members of a derived class, they remain in their original state, and the private
1. Public inheritance means "is-a" (is a) relationship, which is the full inheritance of the interface (not necessarily the full inheritance of the interface implementation). For example, b inherits from a, if it is inherited by public, it means
Public, private, and protected are common inheritance methods.
1. Public inheritance)
Public inheritance is characterized by the original state of both the public members of the base class and the protected members as the members of the derived
Public and private inheritance (private), protected inheritance (protected) are three commonly used methods of inheritance. 1. Public inheritance Public inheritance is characterized by public members of the base class and protected members as
1. Concept of inheritanceInheritance is an attribute of C + +, meaning that a new class is derived from an existing class, whereas a derived class inherits some of the private members and member functions of the base class.Public inheritance is the
1. Access range of private, public, and protected access labelsPrivate: It can only be accessed by 1. functions in this class, 2. Other functions.Cannot be accessed by any other user, nor can the object of this class be accessed.
Protected: it can
This chapter describes the relationship of inheritance. You can give an example to illustrate:The parent class is the fruit, the subclass is the Apple, the Apple is a kind of (is-a) fruit, but the fruit is not necessarily apple.Is-a is not the only
The first consideration is a very typical relationship, that is, the relationship between the rectangle and the square:1 classrecantagle{2 Virtual voidSetHeight (int);3 Virtual voidSetWidth (int);4 Virtual intHeightint)Const;5
The inheritance methods in C + + are:Public, private, protected three (they directly affect the members of the derived class, and the rules that their objects access to the base class members).(1) Public: Inheritance keeps the properties of the
Private inheritance for C + + classesWhen declaring a derived class, the inheritance of the base class is specified as private, and a derived class established in private inheritance is called a private derived class (the private derived class), and
Yesterday we learned three ways of inheriting, some of which are very image and share them.First, describe a few terms:1. Base classThe base analogy from which the inheriting class is a more abstract concept, is described in a larger scope. So you
Title, I am a little confused, such as a function of intercepting string length, should I write in common.php or in the parent class (Public inheritance Class)?
Also, what is the difference between these two implementations for performance?
Please
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.