Saturday, May 12, 2012

Inheritance

Points to remember in Inheritance

1.  Base class destructor should be virtual
        -> If it is not , we will end up in memory leak

Base * ptr = new Derived();
 delete ptr ;  // this will call base class's destructor   , not both class's destructor
   
2. Base class's Constructor and destructor should be public
    -> Otherwise will gets compile time issue



No comments:

Post a Comment