Category : union

t2 below causes the following compile error test.cpp:14:15: error: cannot initialize a member subobject of type ‘E’ with an rvalue of type ‘int’ Test t2{2, {{2, 3}}}; ^ test.cpp:14:18: error: cannot initialize a member subobject of type ‘void *’ with an rvalue of type ‘int’ Test t2{2, {{2, 3}}}; How do I initialize the second ..

Read more

I keep getting an error message "error: incompatible types in assignment of ‘const char[7] to [30]" when accessing the employee name. I know that only one data member of the union can be accessed at one time. Please, help. Thank you! Here is my code: #include <iostream> #include <string> using namespace std; union employee { ..

Read more