C
Chameleon
We have this structure:
-----------------------
struct A {
struct B {
...
} b;
...
struct C {
void no_way_dude();
} c;
};
-----------------------
How can I have access on 'b' from inside of 'no_way_dude()'?
I mean without pass parameters to 'C()' or to 'no_way_dude()'
You can use 'friend' as you wish.
Until now I use:
B &b = *(B*)(((char*) this) - sizeof(B));
But it is totally lame.
If I add a definition between B and C, it will screwed.
Basically I need something like:
off_t rel = (char*) A::C - (char*) A::B;
Any workaround without pass pointers to functions?
-----------------------
struct A {
struct B {
...
} b;
...
struct C {
void no_way_dude();
} c;
};
-----------------------
How can I have access on 'b' from inside of 'no_way_dude()'?
I mean without pass parameters to 'C()' or to 'no_way_dude()'
You can use 'friend' as you wish.
Until now I use:
B &b = *(B*)(((char*) this) - sizeof(B));
But it is totally lame.
If I add a definition between B and C, it will screwed.
Basically I need something like:
off_t rel = (char*) A::C - (char*) A::B;
Any workaround without pass pointers to functions?