Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralStill inheritance... Pin
Bertrand Boichon3-Oct-02 23:32
Bertrand Boichon3-Oct-02 23:32 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 0:01
Tomasz Sowinski4-Oct-02 0:01 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 3:21
Ranjan Banerji4-Oct-02 3:21 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 3:30
Tomasz Sowinski4-Oct-02 3:30 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:09
Ranjan Banerji4-Oct-02 5:09 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:26
Tomasz Sowinski4-Oct-02 5:26 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:34
Ranjan Banerji4-Oct-02 5:34 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:44
Tomasz Sowinski4-Oct-02 5:44 
I don't see your point. You've started with cast to base class and call to operator= which probably cause slicing. Then you argue that it's viable option, because if you don't store the data in base class then you'll lose the advantages of inheritance.

The approach you propose is IMHO dangerous and applicable in rare case when derived classes differ only in their behavior (do not introduce data members). This rare case can exist for a while in given project, but it's trivial to break it by adding data member(s) to derived class. The program will still compile, but it won't work correctly anymore.

So I can't any advantage of using *a=*b where a and b are cast from derived to base.


Ranjan Banerji wrote:
Taking the shape example one could could have the BaseShape class from which which one could derive single color classes and other color classes etc. From which you derive the various shapes etc

Would you cast to BaseShape and use operator= then?

Tomasz Sowinski -- http://www.shooltz.com

*** Si fractum non sit, noli id reficere. ***

GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:47
Ranjan Banerji4-Oct-02 5:47 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 5:55
Tomasz Sowinski4-Oct-02 5:55 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 5:58
Ranjan Banerji4-Oct-02 5:58 
GeneralRe: Still inheritance... Pin
Tomasz Sowinski4-Oct-02 6:13
Tomasz Sowinski4-Oct-02 6:13 
GeneralRe: Still inheritance... Pin
Ranjan Banerji4-Oct-02 6:35
Ranjan Banerji4-Oct-02 6:35 
GeneralInheritance, interfaces and polymorphism... Pin
Bertrand Boichon3-Oct-02 22:57
Bertrand Boichon3-Oct-02 22:57 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski3-Oct-02 23:56
Tomasz Sowinski3-Oct-02 23:56 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon4-Oct-02 13:59
Bertrand Boichon4-Oct-02 13:59 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski5-Oct-02 0:35
Tomasz Sowinski5-Oct-02 0:35 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon5-Oct-02 14:00
Bertrand Boichon5-Oct-02 14:00 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski7-Oct-02 2:18
Tomasz Sowinski7-Oct-02 2:18 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon7-Oct-02 10:20
Bertrand Boichon7-Oct-02 10:20 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski7-Oct-02 11:19
Tomasz Sowinski7-Oct-02 11:19 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon7-Oct-02 11:23
Bertrand Boichon7-Oct-02 11:23 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Tomasz Sowinski8-Oct-02 4:26
Tomasz Sowinski8-Oct-02 4:26 
GeneralRe: Inheritance, interfaces and polymorphism... Pin
Bertrand Boichon8-Oct-02 8:19
Bertrand Boichon8-Oct-02 8:19 
GeneralToolbar button state (enable/disable) Pin
Daniel Strigl3-Oct-02 22:40
Daniel Strigl3-Oct-02 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.