DEV Community

Discussion on: Modern Full-Stack Developer Tech Stack 2021

 
ritin profile image
Ritin • Edited
class A                     { public: void eat(){ cout<<"A";} }
class B: virtual public A   { public: void eat(){ cout<<"B";} }; 
class C: virtual public A   { public: void eat(){ cout<<"C";} }; 
class D: public         B,C { public: void eat(){ cout<<"D";} }; 

int main(){ 
    A *a = new D(); 
    a->eat(); 
} 

I…

  1. Bloated Code. Why should you have to write code for Class C and Class B? When All you want todo is use Class D

  2. You have to worry about the whole Heirarchy (eg, the whole jungle).
    Debuging becomes harder. On instantiation of D was B called or was it C?

The above example is the simplest to illustrate the point. Imagine production scenarios with deep heirarchy.

Thread Thread
 
efpage profile image
Eckehard

Why do you do it this way, if there is a simpler and better approach? You can use a hammer to drill a hole, but maybe that is the wrong tool for the task.