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?

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

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.

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.