Mike Ghan writes:
(...)
> dwFlags member. So with one dwFlags value, the data type LPCSTR
> would be expected (demanded) by the C compiler, while a different
> dwFlags value would expect the data type LPCDLGTEMPLATE.
Unfortunately nothing is expected (demanded) by the C/C++
compiler. Unions are only an abstraction for the programmer. Some kind
of implicite typecasting. If you extract an value from a union, the
compiler is NOT able to check if you take the right one; in opposition
to a Pascal/Modula/Oberon compiler :-(
I try to avoid its usage whenever possible! But sometimes you need it.
You can see a union as a generic bag that may contain ONE gift of any
of the types it is able to wrap. As C/C++ is typechecked (more or
less), you sometimes need such stuff to have functions that are able
to deal with more than one kind of parameter. Using structs would be
even more waste of memory than using unions here.
(...)
Clemens.
-- Clemens Hintze mailto: c.hintze_at_gmx.netReceived on Mon Oct 30 2000 - 23:45:48 PST
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.