PDA

View Full Version : subtyping and specilition in c++ 2011



saneha
05-02-2011, 06:18 AM
subtyping and specilition

Vuhelper
05-02-2011, 06:18 AM
In simple words, i would like to say that as you know very well about the concept of inheritance in which derived class has the capability to own all the member functions and data members of its base class and perform different functions by using these as per needs.

Secondly, as you also know very well that Inheritance "is a" relationship i.e Triangle is a Shape, so in this sentence Triangle is the derived class of Shape.

Definitely, Triangle owns all the functionality of its base class Shape. Lets suppose there is a function"Draw" in its base class that can be accessed by an Object of Triangle and use it. But, in order to draw a triangle , some extension is required in the function Draw. So, this extension in the function of base class that is used by derived object as per needs is called extension in the existing functionality and is also known as subtyping.

Where as Specialization is somehow different in such a way that you restrict the base class functionality as a whole, partially use of base class function by defining some constraints.