&X == &X.member ?

G

Gernot Frisch

Hi,

can I design a class, so that &Class == &Class.member?

class MyStr
{
MyStr();
void foo();

char* member;
};

How can I access the member data, if I get a void* to MyStr object?


--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
V

Victor Bazarov

Gernot said:
can I design a class, so that &Class == &Class.member?

You mean &object == &object.member, don't you?
class MyStr
{
MyStr();
void foo();

char* member;
};

How can I access the member data, if I get a void* to MyStr object?

Usually when you get a 'void*', you just static_cast it back to MyStr*
and access members normally as you would with a pointer to an object.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top