class A
{
protected:
void func1() //DO I need to call this virtual?
};
class B
{
protected:
void func1() //and this one as well?
};
class Derived: public A, public B
{
public:
//here define func1 where in the code there is
//if(statement) {B::func1()} else {A::func1()}
};
如何覆蓋func1?或者你可以定義它用於覆蓋多繼承函數的語法
class Derived: public A, public B
{
public:
void func1()
};
沒有任何虛擬或重寫?我不明白可訪問性。謝謝。
這不是幾乎相同的問題,你問幾分鐘之前的問題? http://stackoverflow.com/questions/19763903/multiple-inheritance-same-variable-name – dhein
是的,但它是一個變量而不是一個函數。這個問題要求重寫該函數。 –
但無論如何,我不明白你的問題?你不能在類定義中使用if語句,對嗎? – dhein