Reputation: 1763
I saw this interview question online. Sadly, I can not figure out such a thing... functions, constructor, destructors
btw, I think that struct and class are nearly the same in C++ except that members of a class are private by default, whereas members of a struct are public by default. Inheritance between classes is also private by default, and inheritance between structs is public by default.
And union is different from struct because it all the members at the same spot.
thanks
Upvotes: 4
Views: 203
Reputation: 355207
A union cannot have base classes.
A union also cannot have any data members with nontrivial special member functions, virtual member functions, static data members, or reference data members, but these would appear in the definition of the union. A union cannot be used as a base class, but this applies only to other class declarations, not to the declaration of the union itself.
Upvotes: 6