转自:
http://blog.csdn.net/hairetz/article/details/4153252
#include<iostream>
#include<stdio.h>
using namespace std;
class test
{
public:
test(int i){ m_i=i;}
test(){};
void hello()
{
printf("hello\n");
}
private:
int m_i;
};
int main()
{
test *p=new test();
p->hello();
p=NULL;
p->hello();
}
/****
hello
hello 为何
p=NULL;
p->hello();这样之后,NULL->hello()也依然有效呢?
****/
#include<iostream>
#include<stdio.h>
using namespace std;
class test
{
public:
test(int i){ m_i=i;}
test(){}
void hello()
{
printf("hello\n");
}
private:
int m_i;
};
typedef void (test::*HELLO_FUNC)();
int main()
{
test *p=new test();
test q;
p->hello();
HELLO_FUNC phello_fun=&test::hello;
printf("%p\n",phello_fun);
p=NULL;
//phello_fun=&test::hello;
printf("%p\n",phello_fun);
/**
hello
0041C9CC
0041C9CC
**/
}