0

i know:
- &varname is the adress of varname;
- *varname is the value of adressed variable.
but:

void *Vvariant=NULL;

friend ostream& operator <<(ostream &os,const variant2 &obj)
{
    os << obj.Vvariant; //how can i get the value of adressed variable?
    return os;
}

how can i get the value of adressed variable?

3
Contributors
5
Replies
24
Views
3 Years
Discussion Span
Last Post by cambalinho
0

Just dereference it: *obj.Vvariant. But since pointers to void cannot be dereferenced, you still need to cast Vvariant to something else.

Edited by deceptikon

0

What exactly is Vvariant supposed to be? It's impossible to get the value of a void* (without typecasting it first), and it's dangerous to dereference a pointer that is NULL.

0

without typecasting, can i get the adressed values?
seems that i can't see what it is the type

Edited by cambalinho

0

without typecasting, can i get the adressed values?

Nope. You can get just the bytes of the pointed to value by casting to char*, but without knowing what they represent, it's not terribly useful.

seems that i can't see what it is the type

You knew the type when you assigned a value to that void pointer, right? Save it so that you can recall it later.

0

yah.. thanks for all
(seems that when i'm logined, i don't recive the mail notifications)

Edited by cambalinho

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.