企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 基类和派生类具有相同成员时 <details> <summary>main.cpp</summary> ``` #include <iostream> #include <string> using namespace std; class A { public: void show() { cout << "A-show"<<endl; } }; class B:public A { public: void show(){ cout<< "B-show"<< endl; A::show(); } }; int main() { B b; b.show(); return 0; } ``` </details> <br/> ## 实例中调用父类 ``` B b; b.show(); b.A::show(); ``` ## 多重继承的调用方法 ``` void show(){ A1::show(); A2::show(); } ```