C++
Programming and Technical
What is a union?
Read Solution (Total 2)
-
- we can use a single memory location for more than one variable this is called union.
union myUnion{
int var1;
long var2;
} newUnion;
share a single memory location for a variable myVar1 and use the same location for myVar2 of different data type. - 10 years agoHelpfull: Yes(0) No(0)
- A union is a user-defined data or class type that, at any given time, contains only one object from its list of members. The object can be an array or a class type).
fr e.g -
#include
using namespace std;
union NumericType
{
int iValue;
long lValue;
double dValue;
};
int main()
{
union NumericType Values = { 10 }; // iValue = 10
cout - 9 years agoHelpfull: Yes(0) No(0)
C++ Other Question