Nitesh
Nitesh

Reputation: 315

What is the difference between C unions and C++ unions?

What are some major differences between unions in C and C++?

Upvotes: 3

Views: 493

Answers (1)

Bathsheba
Bathsheba

Reputation: 234835

In a nutshell, a C++ union can have constructors and destructors, and non-virtual functions. (Note that a C++ union cannot have a base class and cannot be a base class.)

Everything else is pretty much the same between C and C++.

Upvotes: 9

Related Questions