Posts

Showing posts from January, 2024

Multipath inheritance :There are 2 Ways to Avoid this Ambiguity:

  6. A special case of hybrid inheritance: Multipath inheritance :  A derived class with two base classes and these two base classes have one common base class is called multipath inheritance. Ambiguity can arise in this type of inheritance.  Example: CPP // C++ program demonstrating ambiguity in Multipath // Inheritance   #include <iostream> using namespace std;   class ClassA { public :      int a; };   class ClassB : public ClassA { public :      int b; };   class ClassC : public ClassA { public :      int c; };   class ClassD : public ClassB, public ClassC { public :      int d; };   int main() {      ClassD obj;        // obj.a = 10;                  // Statement 1, Error      // obj.a = 100...