考虑是否有这样的基类
class base1{
protected:
virtual void dosomething1(void)=0;
};
class base2{
protected:
void someprint(void){
std::cout<<"someprint";
};
};
class derived: public base1, public base2{
public:
void dosomething1(void){
std::cout<<"do something 1";
};
};
int main(){
base1* ptr = new derived;
ptr->dosomething1();
return 0;
}
在这里,我们可以将基类ptr用于从2个基类继承的派生类吗?有效吗?