C + + base class and derived class conversionsIn public inheritance, in private inheritance and protection inheritance, only public inheritance can preserve the characteristics of the base class, it retains all members of the base class except
1. member functions that cannot be automatically inherited
Constructor (including copy constructor)
Destructor= Operator
Ii. Inheritance and constructor
The constructor of the base class is not inherited. You must declare your own constructor In
Very detailed! Reprint LinkConversion of C + + base classes to derived classesIn public inheritance, private inheritance, and protection inheritance, only public inheritance preserves the characteristics of the base class well, preserving all
Object-Oriented Programming -- define basic classes and derived classes [continued]
IV,VirtualAnd other member functions
Function calls in C ++ do not use dynamic binding by default. To trigger dynamic binding, two conditions must be met:
1) only
The example in this article explains the transformations between the base class and the derived class in C + +. It will help to understand the object-oriented programming of C + +. Note here: The premise of this example is that the derived class
Derived class to base class:When calling a function:The object of the derived class is passed to the function to be referenced by the base class. At this time, the type conversion from the derived class to the base class does not occur. Because the
4.5 Assignment compatibility relationship between a base class and a derived class objectUnder certain conditions, type conversions can be made between different types of data, such as the ability to assign integer data to a double type
[. Net you must know] (6): go deep into the keywords --- base and this
Author: anytao
This article introduces the following:
Basic object-oriented concepts
Basic keywords
This keyword is easy to understand.
1.
C ++ forced type conversion and forced type conversion
The forced Type conversion (Type Cast) of the C style is very simple. No matter what Type conversion is:
TYPE B = (TYPE)
The C ++ style type conversion provides four types of conversion
C + + notes: Derived classes to base class conversions to accessibility
to determine whether a conversion to a base class is accessible, you can consider whether the public member of the base class is accessible and, if so, that the conversion is
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.