G
Guest
I am trying to migrate code to MSVS 2005. I found some code trying to take
sizeof a member in a nested struct, see below. I know the typedef is wacky,
probably a C coder who did not know C++ well. Now, to me, neither sizeof()
looks right, I thought there were restrictions on that kind of thing.
Apparently I can use the second variation, but that looks iffy to me as well.
Is the best(preferred?) way something like this?
S tempS; sizeof(tempS.x);
class C
{
typedef struct
{
int x;
} S;
void f()
{
sizeof(C::S::x); // Used to work
this->S::x; // Still works
}
};
sizeof a member in a nested struct, see below. I know the typedef is wacky,
probably a C coder who did not know C++ well. Now, to me, neither sizeof()
looks right, I thought there were restrictions on that kind of thing.
Apparently I can use the second variation, but that looks iffy to me as well.
Is the best(preferred?) way something like this?
S tempS; sizeof(tempS.x);
class C
{
typedef struct
{
int x;
} S;
void f()
{
sizeof(C::S::x); // Used to work
this->S::x; // Still works
}
};