标签:out system iostream str ace 同名成员函数 main 版本 name
#include<iostream> using namespace std; class Base { public: Base() { m_A = 100; } void func() { cout << "Base func()调用" << endl; } void func(int a) { cout << "Base func(int a)调用" << endl; } int m_A; }; class Son :public Base { public: Son() { m_A = 200; } void func() { cout << "Son func()调用" << endl; } int m_A; }; void test01() { Son s; cout << "Son m_A = " << s.m_A << endl; cout << "Base m_A = " << s.Base::m_A << endl; s.func(); s.Base::func(); //s.func(100);报错,子类的同名成员函数隐藏父类的所有同名成员函数,包括重载版本 s.Base::func(100); } int main() { test01(); system("pause"); return 0; }
标签:out system iostream str ace 同名成员函数 main 版本 name
原文地址:https://www.cnblogs.com/lyt888/p/12488665.html