[C++]空指针访问静态成员函数

class VolumeManager {

public :

static void Hello() {cout «“Hello World!“};

}

void main(){

VolumeManager *vm = NULL;

//Ok to run, like VolumeManager::Hello();

//because there is no this pointer.

//C++ is not C, In general in C++, it should be Hello(this), in this case no this;

vm->Hello();

}

你可能感兴趣的:([C++]空指针访问静态成员函数)