ok...
int myInt = 5;
int *pmyInt = &myInt
if you return pmyInt it gives the address of the variable myInt and *pmyInt gives the value of myInt which is 5.
What the hell is
int **psomething
???
int myInt = 5;
int *pmyInt = &myInt
int **ppmyInt = &pmyInt
*ppmyInt return the address of pmyInt and **ppmyInt the value or what?
** means "a pointer to a pointer" (yep, its possible since pointers are really just variables that contain an offset).
So **ppmyInt should give you the value of myInt since your just dereferencing it like so: ppmyint->pmyint->myInt.
Brain hurt yet?
----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.
Edited by - The Senshi on July 24, 2000 4:28:38 PM
So **ppmyInt should give you the value of myInt since your just dereferencing it like so: ppmyint->pmyint->myInt.
Brain hurt yet?
----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.
Edited by - The Senshi on July 24, 2000 4:28:38 PM
Well, *ppmyInt will return myInt''s address, not the address of pmyInt.
Yes, **ppmyInt will return the value in myInt.
-Mezz
Yes, **ppmyInt will return the value in myInt.
-Mezz
July 24, 2000 03:32 PM
Something is a Something
Something *p is a pointer to a Something.
Something **pp is a pointer to a pointer to a Something.
etc.
In your example *ppmyInt is a pointer to your int.
**ppmyInt is the int itself.
int myInt = 5; // The value of myInt is 5
int *pmyInt = &myInt // The value of pmyInt is the address of myInt
int *ppmyInt = &pmyInt // The value of ppmyInt is the address of pmyInt
*ppmyInt is not the address of pmyInt, it''s the value of pmyInt (the value of the pointer not the int).
Something *p is a pointer to a Something.
Something **pp is a pointer to a pointer to a Something.
etc.
In your example *ppmyInt is a pointer to your int.
**ppmyInt is the int itself.
int myInt = 5; // The value of myInt is 5
int *pmyInt = &myInt // The value of pmyInt is the address of myInt
int *ppmyInt = &pmyInt // The value of ppmyInt is the address of pmyInt
*ppmyInt is not the address of pmyInt, it''s the value of pmyInt (the value of the pointer not the int).
that''s not confusing! this is: ****************p
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
does **ppmyInt returns the value of myInt or the address of it(which is the value of pmyInt)???
does **ppmyInt returns the value of myInt or the address of it(which is the value of pmyInt)???
check it out......!!!
#include
int main()
{
int myInt = 5;
int * pmyInt = &myInt
int ** ppmyInt = &pmyInt
cout << "myInt: " << myInt << "\n";
cout << "&myInt: " << &myInt << "\n";
cout << "pmyInt: " << pmyInt << "\n";
cout << "&pmyInt: " << &pmyInt << "\n";
cout << "*pmyInt: " << *pmyInt << "\n";
cout << "ppmyInt: " << ppmyInt << "\n";
cout << "&ppmyInt: " << &ppmyInt << "\n";
cout << "*ppmyInt: " << *ppmyInt << "\n";
cout << "**ppmyInt: " << **ppmyInt << "\n";
return (0);
}
OUTPUT:
myInt: 5
&myInt: 0x0065FDF4
pmyInt: 0x0065FDF4
&pmyInt: 0x0065FDF0
*pmyInt: 5
ppmyInt: 0x0065FDF0
&ppmyInt: 0x0065FDEC
*ppmyInt: 0x0065FDF4
**ppmyInt: 5
eh? how''s that! good way to answer a question yourself.
#include
int main()
{
int myInt = 5;
int * pmyInt = &myInt
int ** ppmyInt = &pmyInt
cout << "myInt: " << myInt << "\n";
cout << "&myInt: " << &myInt << "\n";
cout << "pmyInt: " << pmyInt << "\n";
cout << "&pmyInt: " << &pmyInt << "\n";
cout << "*pmyInt: " << *pmyInt << "\n";
cout << "ppmyInt: " << ppmyInt << "\n";
cout << "&ppmyInt: " << &ppmyInt << "\n";
cout << "*ppmyInt: " << *ppmyInt << "\n";
cout << "**ppmyInt: " << **ppmyInt << "\n";
return (0);
}
OUTPUT:
myInt: 5
&myInt: 0x0065FDF4
pmyInt: 0x0065FDF4
&pmyInt: 0x0065FDF0
*pmyInt: 5
ppmyInt: 0x0065FDF0
&ppmyInt: 0x0065FDEC
*ppmyInt: 0x0065FDF4
**ppmyInt: 5
eh? how''s that! good way to answer a question yourself.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement