下面两段代码的输出分别是什么?
class Base{
public:
virtual void Print() const{
cout << "Print in Base" << endl;
}
};
class Derive::public base
{
public:
void Print() const{
cout << "Print in Derive" << endl;
}
};
void Print(const Base* base){
base->Print();
}
int main(){
Base b;
Derive d;
print(&b);
print(&d);
return 0;
}
class Base{
public:
void Print() const{
cout << "Print in Base" << endl;
}
};
class Derive::public base
{
public:
void Print() const{
cout << "Print in Derive" << endl;
}
};
void Print(const Base* base){
base->Print();
}
int main(){
Base b;
Derive d;
print(&b);
print(&d);
return 0;
}