
31 Jul
2011
31 Jul
'11
8:51 p.m.
On 07/31/11 15:58, Ertugrul Soeylemez wrote:
Unions work, too, but they are not nearly as clean. In general, avoid unions in C++, even though they seem to be a natural way to express ADTs. They really are not. Class hierarchies are the way to go.
Or boost::variant. It's actual algebraic data types, at the expense of mighty weird syntax for pattern-matching because the Boost developers had to come up with something that compiled in C++. ~Isaac