Author |
Message |
hamid1455
|
Posted: Sun Mar 31, 2013 1:04 pm Post subject: cout with pointers |
|
|
Say I have a pointer like this:
double meow = 0;
double * pDouble = &meow;
Then cout << &pDouble; will print the memory address that pDouble is pointing to, right?
So then what is the memory address that I get when I output just plain old pDouble?
Also, outputting *pDouble gives me the value of the pointer or the value of what the pointer is pointing to?
Thanks in advance guys. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
linuxp
|
Posted: Sun Mar 31, 2013 1:13 pm Post subject: RE:cout with pointers |
|
|
pDouble = &meow = address of meow
*pDouble = meow = value of meow
&pDouble = address of pDouble itself |
|
|
|
|
|
hamid1455
|
Posted: Sun Mar 31, 2013 1:42 pm Post subject: Re: cout with pointers |
|
|
so I could make a pointer that points to another pointer? |
|
|
|
|
|
nullptr
|
Posted: Sun Mar 31, 2013 3:34 pm Post subject: Re: cout with pointers |
|
|
Yes. And you could make a pointer that points to a pointer that points to a pointer if you wanted to. int************ p; is valid C++ code, though I can't think why you would need that many levels of pointers. |
|
|
|
|
|
|