隐藏基类的方法与调用
[cpp]#include <iostream>
using namespace std;
class mam{
public:
void move() const {cout << "mammal move one step.\n"; }
void move(int distance)const {
cout << "mommal move";
cout <<" " << distance << " " <<"steps." << endl;
}
protected:
int age;
int weight;
};
class dog:public mam {
public:
void move()const { cout << "dog move 5 steps. " << endl; }
};
int main()
{
mam animal;
dog fido;
animal.move();
animal.move(2);
fido.move();
fido.mam::move(10); //调用基类的方法。
return 0;
}
补充:软件开发 , C++ ,