The Broad Discussion Board
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Inheritance

Go down

      Inheritance Empty Inheritance

Post by meodingu Tue Jan 11, 2011 4:30 pm

Inheritance

Inheritance allows one data type to acquire properties of other data types. Inheritance from a base class may be declared as public, protected, or private. This access specifier determines whether unrelated and derived classes can access the inherited public and protected members of the base class. Only public inheritance corresponds to what is usually meant by "inheritance". The other two forms are much less frequently used. If the access specifier is omitted, a "class" inherits privately, while a "struct" inherits publicly. Base classes may be declared as virtual; this is called virtual inheritance. Virtual inheritance ensures that only one instance of a base class exists in the inheritance graph, avoiding some of the ambiguity problems of multiple inheritance.

Multiple inheritance is a C++ feature not found in most other languages. Multiple inheritance allows a class to be derived from more than one base class; this allows for more elaborate inheritance relationships. For example, a "Flying Cat" class can inherit from both "Cat" and "Flying Mammal". Some other languages, such as Java or C#, accomplish something similar (although more limited) by allowing inheritance of multiple interfaces while restricting the number of base classes to one (interfaces, unlike classes, provide only declarations of member functions, no implementation or member data). An interface as in Java and C# can be defined in C++ as a class containing only pure virtual functions, often known as an abstract base class or "ABC". The member functions of such an abstract base classes are normally explicitly defined in the derived class, not inherited implicitly.

Property Management California
full service movers
meodingu
meodingu
Member
Member

Male Posts : 153
BDB Credits : 421
Rep : 0
Age : 39
Location : vn hp
Job/hobbies : studient

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum