Click here to Skip to main content
15,883,925 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
PJ Arends26-Feb-06 11:13
professionalPJ Arends26-Feb-06 11:13 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 3:17
Tom Moore26-Feb-06 3:17 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
Gary R. Wheeler26-Feb-06 5:22
Gary R. Wheeler26-Feb-06 5:22 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
includeh1026-Feb-06 3:19
includeh1026-Feb-06 3:19 
GeneralRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 3:34
Tom Moore26-Feb-06 3:34 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Hamid_RT26-Feb-06 3:48
Hamid_RT26-Feb-06 3:48 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
Tom Moore26-Feb-06 6:10
Tom Moore26-Feb-06 6:10 
AnswerRe: How does the using the address of operator work in Visual C++? Pin
PJ Arends26-Feb-06 11:08
professionalPJ Arends26-Feb-06 11:08 
Tom Moore wrote:
Whats the difference between :

GetWindowRect(&rc); and

GetWindowRect(rc);


The function declaration for GetWindowRect is CWnd::GetWindowRect(LPRECT lpRect) const; so it takes a pointer to a RECT structure as it's parameter. The reason why you can pass a CRect object, either as a pointer or by 'reference' (remember that the values of the window rectangle are copied into the CRect object, so you can not pass it in using the copy c'tor) is because the CRect class is derived from the RECT structure and has member operator LPRECT. If you pass it by address, GetWindowRect() assumes that you passed in the address of a RECT structure, or the base class, and it works from there. If you pass it by reference, then the CRect::operator LPRECT() kicks in to pass it's own address ( return this; ).

It's all in the magic of overloaded operators. So the difference between the two examples you gave is that there is really no difference functionally, although passing by address will save a few CPU cycles as it saves a call to the CRect::operator LPRECT


You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --


Within you lies the power for good - Use it!
AnswerRe: How does the using the address of operator work in Visual C++? Pin
David Crow27-Feb-06 3:37
David Crow27-Feb-06 3:37 
QuestionMessage Box being hidden Pin
braveheartkenya26-Feb-06 2:04
braveheartkenya26-Feb-06 2:04 
AnswerRe: Message Box being hidden Pin
includeh1026-Feb-06 3:21
includeh1026-Feb-06 3:21 
GeneralRe: Message Box being hidden Pin
braveheartkenya26-Feb-06 4:52
braveheartkenya26-Feb-06 4:52 
AnswerRe: Message Box being hidden Pin
FarPointer26-Feb-06 3:37
FarPointer26-Feb-06 3:37 
GeneralRe: Message Box being hidden Pin
braveheartkenya26-Feb-06 4:56
braveheartkenya26-Feb-06 4:56 
GeneralRe: Message Box being hidden Pin
FarPointer26-Feb-06 5:11
FarPointer26-Feb-06 5:11 
GeneralRe: Message Box being hidden Pin
Gary R. Wheeler26-Feb-06 5:31
Gary R. Wheeler26-Feb-06 5:31 
GeneralRe: Message Box being hidden Pin
braveheartkenya26-Feb-06 6:05
braveheartkenya26-Feb-06 6:05 
GeneralRe: Message Box being hidden Pin
Ryan Binns26-Feb-06 17:19
Ryan Binns26-Feb-06 17:19 
GeneralRe: Message Box being hidden Pin
braveheartkenya27-Feb-06 7:21
braveheartkenya27-Feb-06 7:21 
GeneralRe: Message Box being hidden Pin
Nibu babu thomas26-Feb-06 18:27
Nibu babu thomas26-Feb-06 18:27 
GeneralRe: Message Box being hidden Pin
braveheartkenya27-Feb-06 7:25
braveheartkenya27-Feb-06 7:25 
QuestionHow to use LB_SETCOUNT message for MFC CListBox class? Pin
oleetron26-Feb-06 2:01
oleetron26-Feb-06 2:01 
AnswerRe: How to use LB_SETCOUNT message for MFC CListBox class? Pin
Ryan Binns26-Feb-06 17:20
Ryan Binns26-Feb-06 17:20 
AnswerRe: How to use LB_SETCOUNT message for MFC CListBox class? Pin
ashesh deep31-Aug-09 2:03
ashesh deep31-Aug-09 2:03 
QuestionProblem about IHTMLDocument2->wirte() , plz ! Pin
Leesen25-Feb-06 21:31
Leesen25-Feb-06 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.