#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

但是,令我震惊的是

树莓派这逼玩意,没有赋值地址,也能访问到相应的类成员函数。