SOrry guys to disturb you all... I just need a little help , can some one please give me a brief introduction to pointer...

also i have some question, what does these mean

int i;
cout<<i (mean to print i)
cout<<*i (what does it mean)
cout<<**i (what does this mean)
cout<<&i ( address of i)

Thank you.....


(int*())buffer (what does this mean).

Edited by Majestics: n/a

5 Years
Discussion Span
Last Post by Narue

can some one please give me a brief introduction to pointer...

A pointer is a variable that holds the address of another object. A pointer can be dereferenced to access the object stored at the address.

cout<<i (mean to print i)

i is uninitialized, but yes.

cout<<*i (what does it mean)

It means nothing. i is not a pointer, so dereferencing is not a meaningful operation.

cout<<**i (what does this mean)

It means nothing. i is not a pointer to a pointer. If one level of indirection isn't valid, two is also invalid.

cout<<&i ( address of i)


(int*())buffer (what does this mean).

It means you don't know what you're doing. ;) At a high level it's casting the buffer object to a function taking no arguments and returning a pointer to int. But since a function type cannot be the target of a cast, the entire expression is invalid. You can cast to a pointer to a function though, assuming buffer exists and the conversion is meaningful:

int (*fp)() = (int(*)())buffer;

Votes + Comments
Extremely Helpful

Please answer this question as well

int *p;
what does these mean?
cout<<&p (Especially what it mean)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.