Re: Antwort: Re: [Dev-C++] What's the difference?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2003-03-04 08:38:46
|
Read it as "the address of" if you are using pointers. for example
int NumberOfEmails = 7;
// Create a pointer, QuantityOfEmails, and make it point to
// the (memory) address of NumberOfEmails.
int* QuantityOfEmails = &NumberOfEmails;
So now we can do
std::cout << *QuantityOfEmails << std::endl; // Outputs '7' to screen
If you are using it with functions...
void FunctionA(int& FreshInt)
{
FreshInt = 10;
}
It means the function takes a REFERENCE to the integer passed in, i.e. any
change made in the function affects the original. So the following code
// Change the ORIGINAL
void FunctionA(int& FreshInt)
{
FreshInt = 10;
}
and
// Change a COPY - changes are lost when function ends.
void FunctionA(int FreshInt)
{
FreshInt = 10;
}
are different.
Let us know if you need more help.
Daniel
>From: "Thomas Stoehr" <tho...@vo...>
>To: dev...@li...
>Subject: Antwort: Re: [Dev-C++] What's the difference?
>Date: Tue, 4 Mar 2003 08:53:54 +0100
>
>this question was also very interesting for me.
>But I have one more question to the pointer story.
>What does the "&" sign mean? When do I need that sign.
>Sorry I know that is a basic question but i do not understand it int the
>book I read
>
>Thanks
>
>thomas
_________________________________________________________________
Chat online in real time with MSN Messenger http://messenger.msn.co.uk
|