The problem with inheritence is that it is compile time(i.e a class A inheriting from class B cannot be modified again) whereas composition can be used to change the objects during runtime(by having a base class pointer we can change the objects runtime).
Correct me if i'm wrong. On Sun, Jun 26, 2011 at 7:13 AM, HowTechStuffWorks < [email protected]> wrote: > Why Composition is said to be good ahead of inheritance. I am just > learning C++ and it was said inheritance can be handled only by expert > programmers, but I dont see anything like that. Can some one give me > an example. Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- regards, chinna. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
