Answers for "multiple inheritance in c++"

C++
6

multiple inheritance in c++

#include<iostream> 
using namespace std; 

class A 
{ 
public: 
A() { cout << "A's constructor called" << endl; } 
}; 

class B 
{ 
public: 
B() { cout << "B's constructor called" << endl; } 
}; 

class C: public B, public A // Note the order 
{ 
public: 
C() { cout << "C's constructor called" << endl; } 
}; 

int main() 
{ 
	C c; 
	return 0; 
}
Posted by: Guest on August-17-2021
1

Diamond inheritance

The "diamond problem" (sometimes referred to as the "Deadly Diamond of Death") is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C
If there is a method in A that B and C have overridden, and D does not override it, then which class of the method does D inherit: that of B, or that of C?
Posted by: Guest on June-03-2020

Code answers related to "multiple inheritance in c++"

Browse Popular Code Answers by Language