Re: question about anonymous union usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux