空指针调用函数【可以成功】

  写了个小程序,通过一个指针调用类的方法,结果,指针为空,调用类的方法却成功了,c++也太严格了,汗颜。

#include<iostream>
 class testClass 
{
   public:
    int init()
{ 
    std::cout<<"start init"<<std::endl;
}

};

int main()
{

testClass* pTestClass = NULL;
pTestClass->init();
return 0;
}
原文地址:https://www.cnblogs.com/yuanxingdefan/p/3343591.html