#include <iostream>
using namespace std;
namespace simple {
class InterfaceA {
public:
virtual ~InterfaceA() {}
virtual int MethodOne() const = 0;
};
class InterfaceB : virtual public InterfaceA { // <-- note the virtual keyword
public:
~InterfaceB() override {}
virtual int MethodTwo() const = 0;
};
class ImplA : virtual public InterfaceA { // <-- note the virtual keyword
public:
ImplA(int to_return);
~ImplA() override {}
int MethodOne() const override;
private:
int to_return_;
};
class ImplB : public InterfaceB, public ImplA {
public:
ImplB();
~ImplB() override {}
//int MethodOne() const override;
int MethodTwo() const override;
};
ImplA::ImplA(int to_return) : to_return_(to_return) {}
int ImplA::MethodOne() const { return to_return_; }
ImplB::ImplB() : ImplA(5) {}
// int ImplB::MethodOne() const { return ImplA::MethodOne(); }
int ImplB::MethodTwo() const { return 2; }
} // namespace simple
int main() {
simple::ImplA implA(100);
cout << implA.MethodOne() << endl << endl;
simple::ImplB implB;
cout << implB.MethodOne() << endl;
cout << implB.MethodTwo() << endl;
return 0;
}