My issue
oupput is not coming i am trieng hard to complte this problem
My code
#include <iostream>
using namespace std;
class A {
protected:
int a;
public:
A(int x) : a(x) {}
virtual void display() {
cout << "a: " << a << endl;
}
};
class B : virtual public A {
protected:
int b;
public:
B(int x, int y) : A(x), b(y) {}
void display() override {
cout << "a: " << a << "\nb: " << b << endl;
}
};
class C : virtual public A {
protected:
int c;
public:
C(int x, int z) : A(x), c(z) {}
void display() override {
cout << "a: " << a << "\nc: " << c << endl;
}
};
class D : public B, public C {
public:
D(int x, int y, int z) : A(x), B(x, y), C(x, z) {}
void display() override {
cout << "a: " << a << "\nb: " << b << "\nc: " << c << endl;
}
};
int main() {
int a, b, c;
cin >> a >> b >> c;
D obj(a, b, c);
obj.display();
return 0;
}
Learning course: Learn Programming and Problem Solving using C++
Problem Link: https://www.codechef.com/learn/course/sit-cpp-fall/SITFALL60/problems/CPPFALL431