For reference parameters of the problem

Category: C/C++ -> C++ Author: yan5257 Date: 2003-04-28 12:21:57
2003-04-28 12:21:57
GetWindowText MSDN Help function prototype is:
void GetWindowText (CString & rString) const;
GetWindowText function parameter is a reference to a CString object, and now I define a CString Object str; Why can GetWindowText str as an argument to a function, namely GetWindowText (str) const;? ? ? Parameter is not a reference to the object it? Why is the object itself can be? Thank you very confused answer ~ ~ ~
2003-04-28 12:27:18
object itself can be assigned to cite ah
2003-04-28 12:41:47
automatic type conversion made up.
2003-04-28 12:56:08
references the original object alias; in void GetWindowText (CString & rString) const in rString is you pass a reference to an object, that is, you pass an object alias, the function can be changed you pass through rString objects; in passing parameters when doing an implicit conversion from the left value to the reference, you can see the "C + + primer" a book;
2003-04-28 12:59:23
CString & rString = str;
not wrong
2003-04-28 13:08:22
void GetWindowText (CString & rString) const;

CString & rString = str

That's it, do not understand your confusion is what?
2003-04-28 13:18:48
references are not pointers, but without a real space object code only

like spoken language expressed by bbs forum ; the same meaning.

once again need to take an intermediate address operation