#include <iostream>
class myClass
{
public:
static myClass * pmClass;
static int num_St;
public:
int num;
void printNum_St(void){std::cout << num_St <<std::endl;};
void printNum(void){std::cout << num <<std::endl;};
};
myClass *myClass::pmClass = nullptr; //静态变量初始化
int myClass::num_St = 2;
int main()
{
myClass _myclass;//生成一个对象
// myClass::pmClass = &_myclass; //传递对象地址
myClass::pmClass->printNum();
myClass::pmClass->printNum_St();
return 0;
}
报错:
Segmentation fault