I have 2 classes: one basic and one derivative. Also have structure.
struct D;
class A {
public:
virtual D Multiply(D one, D two) {
//realization
return result;
}
virtual D Pow(D one, D two) {
result = this->Multiply(one,two); //#1
return result;
}
};
class B: public virtual A {
public:
virtual D Multiply (D one, D two){
//realization
}
};
Function Multiply have realization in class A. So, this code is good?
B* b = new B();
b->Pow(one,two); // #2
and which function A::Multiply or B::Multiply will called at #2? I think, that this at #1 will point to A-part of B-object.
It will call B::Multiply, this is basic OO principals.