[lug] Can't create union with classes that have copy CTOR's?

LittleViggy at alum.manhattan.edu LittleViggy at alum.manhattan.edu
Fri Mar 22 16:48:58 MST 2002


I guess it has something to do with the fact that classes can have VTables, and 
unions take up only as much memory as the largest item?  Hmmm, I'm not sure I 
understand that, since a vtable really does have a set size ay compile time 
(the function pointer is what is determined at run time) or do I have that 
wrong?

Hmmm, maybe I should invest in Stroustrup's book.  Heh, I've been writing C++ 
for almost 6 years now, and never actually read any of his books (even met the 
man too).

Viggy

"D. Stimits" wrote:
> 
> LittleViggy at alum.manhattan.edu wrote:
> >
> > Hey all,
> >
> > I'm trying to create a union of 5 classes.  All five have copy 
constructors,
> > and the compiler is erroring out.  Albeit, I'm using Microsoft (sorry), but
> > there's nothing in their documentation that says this is specific to M$.
> >
> > Is this ANSI complient?  You can't create a union of classes with copy 
CTOR's?
> > If so, why not?
> 
> Don't know why since it has been a long time since I saw this, but
> you'll find no executable code can be in a union. I don't remember the
> exact explanation, but I do recall I got it from the Stroustrup book,
> third edition.
> 
> D. Stimits,
stimits at idcomm.com

-------------------------------------------------------------
     This message was sent from Peak to Peak Internet.       
 DSL - V.90 modems - Web Hosting and Business connectivity   
          Please visit!  http://www.peakpeak.com             
                    (888)-600-PEAK                           
-------------------------------------------------------------





More information about the LUG mailing list