Containership

  • In Inheritance, if a class B is derived from class A, B has all characteristics of A in addition to its own.
  • Hence you can say that "B is a kind of A". So, inheritance is sometimes called as a "kind of" relationship.
  • There is another kind of relationship called a "has a" relationship, or containership. In OOP, this relation occurs when you have an object of class A in class B as shown.
    For example 
    class A { };
    class B {A a;	// A is contained in B
    };
    
    Click Here For example


Overriding Member Functions << Previous

Next >> Class Hierarchies

Our aim is to provide information to the knowledge seekers.


comments powered by Disqus






Footer1