gregbackus
Programmer
say you have a file like this...
#define CASTING_IS_A_BEAR 200
#include <string.h>
#include <iostream.h>
class thing { public:
char name[32];
thing() { strcpy(name,"greg" }
};
int main(void)
{ void *p;
thing g;
p=(void*)g;
/*
now how do I get to g::name through p?
*/
cout<<(thing*)p.name<<endl; // does not work
return CASTING_IS_A_BEAR;
}
I have dumbed down the example to get to the root of the problem I am having.
I have a class (class A) that includes a pointer to another class (class B) and would
like class B to be able to keep track of the class A's that refer to them.
Any help would be greatly appreciated.
Greg
#define CASTING_IS_A_BEAR 200
#include <string.h>
#include <iostream.h>
class thing { public:
char name[32];
thing() { strcpy(name,"greg" }
};
int main(void)
{ void *p;
thing g;
p=(void*)g;
/*
now how do I get to g::name through p?
*/
cout<<(thing*)p.name<<endl; // does not work
return CASTING_IS_A_BEAR;
}
I have dumbed down the example to get to the root of the problem I am having.
I have a class (class A) that includes a pointer to another class (class B) and would
like class B to be able to keep track of the class A's that refer to them.
Any help would be greatly appreciated.
Greg