Classes: Inheritance
Applies To: C++Builder 1 or higher
Category: C++ Language
- Inheritance is used to inherit the characteristics from another object. Its general form is:
-
class derived_class : access base_class {
};
|
-
- The inheriting class is derived_class and the class from which it inherits is base_class. access describes how access rights are inherited.
-
- If access is protected, public and protected members of the base class becomes protected in the derived class. If access is private, public and protected members become private. Finally, if access is public, public and protected members become public.
-
- Here's an example:
-
- class Base {
- public:
- int Count;
- };
-
- class Derived : public Base {
- public:
- int DerivedCount;
- Derived();
- };
-
- Derived::Derived() {
- DerivedCount = Count = 5;
- }
C++Builder Developer's Network
Copyright © Yoto Yotov