1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| #include<iostream> using namespace std;
class Base { public: static void func() { cout << "Base - static void func()" << endl; } static void func(int a) { cout << "son - static void func(int)" << endl; } };
class son :public Base { public: static void func() { cout << "son - static void func()" << endl; } };
int main() { cout << "通过对象访问" << endl; son s; s.func(); s.Base::func(); cout << "通过类名访问" << endl; son::func(); son::Base::func(); cout << "重载" << endl; son::Base::func(100); return 0; }
|