本文主要是介绍类学习之Use Base keyword to call method in parent class from subclass,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用基础关键字从子类调用父类方法
#include <iostream>
using namespace std;
class Base {public:void display(void) { cout << "This is the base class" << endl; };
};class Derived: public Base {public:void display(void) { cout << "This is the derived class" << endl; };
};
class PP:public Base{public: void display(void){cout<<"<pre name="code" class="cpp">This is the PP class
"<<endl}}int main(void){ Derived my_class; my_class.display(); my_class.Base::display();my_class.PP.display();}
这篇关于类学习之Use Base keyword to call method in parent class from subclass的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!