代码疑云(5)-类成员函数的thiscall约定

代码:

(感谢网友提供的题目)

疑:调用coutHello和coutValue方法有什么问题?

解答:成员函数的地址在编译器编译时给出的,所以是已知的,根据thiscall约定,类的成员函数在编译时编译器会传入一个this指针,通过this指针指向成员变量,在调用couthello时并未用到this指针所以调用正常,而调用coutvalue时,value需要用到this指针,因为此时this是NULL指针,所以会发生内存报错。

======= welcome to my HomePage(http://blog.csdn.net/zhanxinhang) to have a communication =======

posted on 2011-07-08 15:09  程序员新鲜事  阅读(128)  评论(0编辑  收藏  举报