|
-
June 17th, 2011, 04:47 AM
#1
union issues.
#include <iostream.h>
class vehicle
{
public : vehicle()
{
}
int i;
float e;
};
main()
{
union a
{
char k;
int j;
vehicle obj;
};
cout<<sizeof(a)<<endl;
return 0;
}
this code gives compilation error as shown below error C2620: union 'a' : member 'obj' has user-defined constructor or non-trivial default constructor.
But without constructor same code prints 8 bytes...Need to know why defining constructor gives compilation problem ..pls clarify..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|