Read about define base class and derived class, The latest news, videos, and discussion topics about define base class and derived class from alibabacloud.com
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
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
Object-Oriented Programming-Overview, definition of base classes and derived classes
Introduction:
Object-Oriented programming is based on three basic concepts: data abstraction, inheritance, and dynamic binding.
In C ++,Data abstraction using
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
LeeLin blog
(1) When the base class does not have its own constructor, the default bar of the derived class uses the constructor of the base class.(2) When the base class has a self-compiled constructor, you must add a constructor without parameters
(1) When the base class does not have its own constructor, the default bar of the derived class uses the constructor of the base class.(2) When the base class has a self-compiled constructor, you must add a constructor without parameters to the base
As an object-oriented program design, inheritance is a very important feature, the core idea of object-oriented programming (object-oriented programming, OOP) is data abstraction, inheritance and dynamic binding. With the use of data abstraction, we
I. Purpose of introducing inheritance
1. code reuse
The Inheritance and derivation mechanisms of classes enable programmers to get new classes by adding a small amount of code or modifying a small amount of code on the basis of existing classes
There is an assignment-compatible relationship between the base class and the derived class object, because the derived class contains members that inherit from the base class, in the following respects, the required friend can refer to the only
Only a public derived class is a true subtype of the base class, and it inherits the functionality of the base class completely. There is an assignment-compatible relationship between the base class and the derived class object, because the derived
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.