标签:turn space std public ace pac nbsp ret 处理
#include<iostream> using namespace std; class Base { public: static int m_A; static void func() { cout << "Base static func()调用" << endl; } static void func(int a) { cout << "Base static func(int a)调用" << endl; } }; int Base::m_A = 100; class Son :public Base { public: static int m_A; static void func() { cout << "Son static func()调用" << endl; } }; int Son::m_A = 200; void test01() { Son s; cout << "通过对象访问" << endl; cout << "Son m_A = " << s.m_A << endl; cout << "Base m_A = " << s.Base::m_A << endl; cout << "通过类名访问" << endl; cout << "Son m_A = " << Son::m_A << endl; cout << "Base m_A = " << Base::m_A << endl; cout << "Base m_A = " << Son::Base::m_A << endl; } void test02() { Son s; cout << "通过对象访问" << endl; s.func(); s.Base::func(); s.Base::func(100); cout << "通过类名访问" << endl; Son::func(); Son::Base::func(); Son::Base::func(100); } int main() { test01(); cout<<"----------------------"<<endl; test02(); system("pause"); return 0; }
标签:turn space std public ace pac nbsp ret 处理
原文地址:https://www.cnblogs.com/lyt888/p/12488694.html