Can two classes be simultaneously linked by aggregation and inheritance?

  • Moreover, there is a design pattern "Decorator" in which it is used - Andrey NOP

1 answer 1

Sure you may:

class Base { }; class Derived: public Base { Base b; }; int main(int argc, const char * argv[]) { Derived d; } 
  • one
    well, why, and suddenly you want cyclic inheritance, but it does not work ... then aggregation comes to the rescue ... - KoVadim
  • one
    Christmas joke ??? - AR Hovsepyan
  • Pattern Decorator! - Andrei NOP