Click here to Skip to main content
15,879,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
In C, variables can be passed to a function either by-value or by-reference. For example:

// pass-by-value
void foo( int num )
{
    num = 12;
}
...
int x = 5;
printf("%x\n", x); // will print 5
foo(x);
printf("%x\n", x); // will also print 5
 
// pass-by-reference
void foo( int *num )
{
    *num = 12; // change the value pointed to by 'num'
}
...
int x = 5;
printf("%x\n", x); // will print 5
foo(&x);
printf("%x\n", x); // will now print 12
Another consideration is the amount of memory pushed onto the stack when one or the other is used. For integral types such as int, char, and double, there is little, if any, difference between the two. A char is 1 byte, a double is 8 bytes, and a pointer to either is 4 bytes. Where this matters more is when large data structures are being passed to a function. Imagine an object that is 1497 bytes in size. Passing the object by-value will result in 1497 bytes being piushed onto the stack, whereas passing the object by-reference will result in only 4 bytes being pushed onto the stack.


"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

"There is no death, only a change of worlds." - Native American Proverb


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 
AnswerRe: Problem about IHTMLDocument2->wirte() , plz ! Pin
Leesen27-Feb-06 1:53
Leesen27-Feb-06 1:53 

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.