10.1 类似非静态成员函数处理
10.2 如果想访问父类中的成员,加作用域即可
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
class Base {
public:
static void func() {
cout << "父类func()调用" << endl;
}
static void func(int a) {
cout << "父类func(int a)调用" << endl;
}
static int m_a;
};
int Base::m_a = 10;
class Son:public Base {
public:
static void func() {
cout << "子类func()调用" << endl;
}
static int m_a;
};
int Son::m_a = 20;
//静态成员属性 子类可以继承下来
void test01() {
cout << Son::m_a << endl;
//访问父类的m_a
cout << Base::m_a << endl;
Son::func();
Son::Base::func();
//访问 父类中同名的函数
Son::Base::func(5);
}
int main(){
test01();
system("pause");
return 0;
}