关于c ++:回想起来,将’this’作为参考而不是指针会更好吗?

Would making 'this' a reference rather than a pointer be better in retrospect?

本问题已经有最佳答案,请猛点这里访问。

Possible Duplicate:
Why ‘this’ is a pointer and not a reference?

在C++中,EDCOX1的0个原因是不是一个指针,而不是历史语言决定的一个引用?考虑到复制构造函数或赋值运算符都接受对"that的引用,而不是指针,这有点奇怪。

[老实说,我找不到这个问题,尽管它看起来可能是重复的]


从Bjarne Stroustrup的《C++的设计与演化》看,Addison Wesley,1994,PP 39-40:

Sometimes, people ask why this is a pointer rather than a reference and why it is called this rather than self. When this was introduced into C with Classes, the language didn't have references, and C++ borrows its terminology from Simula rather than Smalltalk.


创建this时,该语言中不存在引用。