大家觉得下面的代码能执行吗?注意pTest是NULL,如果觉得能,请给出理由,不能也请给出理由,我是在2000,VC6上执行的下面代码,在另一台机的XP上也通过了
class CTest
{
public:
TestA()
{
int a = 0;
AfxMessageBox("ddddddd");
}
TestB()
{
int a = 0;
}
}*pTest;
BOOL Tt()
{
pTest = NULL;
pTest->TestA();
}
...全文
1549打赏收藏
C++允许用空指针访问方法吗?
大家觉得下面的代码能执行吗?注意pTest是NULL,如果觉得能,请给出理由,不能也请给出理由,我是在2000,VC6上执行的下面代码,在另一台机的XP上也通过了 class CTest { public: TestA() { int a = 0; AfxMessageBox("ddddddd"); } TestB() { int a = 0; } }*pTest; BOOL Tt() { pTest = NULL; pTest->TestA(); }