- class A has a pure virtual method
read()
- class B has an implemented virtual method
read()
- I have a class C that inherits A and B
- Can this happen?
What I'm trying to achieve is that the two base classes A and B complement each other.
So C read()
method would actually call class B read()
class A {
virtual int get_data() = 0;
void print() {
log(get_data());
}
}
class B {
virtual int get_data() {
return 4;
}
}
class C : public A, public B {
}
C my_class;
my_class.print(); // should log 4;
I'm not on my computer nor will have opportunity in the next couple of weeks so I can't test this... but I'm designing the architecture and needed to know if this is possible and if not.. how can this be accomplished!