This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: question about anonymous union usage
Hi Jeff,
> I will have isPseudo_ properly set to identify what type of pointer the
union holds, but I want to ignore it in all SomeClass methods except its
constructors.
You should check for it in all SomeClass methods, and do things like:
void SomeClass::doDance()
{
if(isPseudo_) pseudoVertex_->doDance();
else layoutVertex_->doDance();
};
> If I do this, there will be times that layoutVertex_ will point to a type
of PseudoVertex and I'll treat it like a LayoutVertex.
Then there will be times when the SomeClass object will have a pointer to
PseudoVertex and you'll call the methods as if you had a pointer to
LayoutVertex.
Antics and hijinks ensue.
HTH,
--Eljay