Error C2621
-
I cannot understand what the problem is with this code and why I get this error: error C2621: union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor
struct floatInfoStruct
{
float min;
float max;
float* result;
float test;
};struct intInfoStruct
{
int min;
int max;
int* result;
int test;
};struct timeInfoStruct
{
SECONDS min;
SECONDS max;
SECONDS *result;
TimeFormats Format;
SECONDS test;
};struct angleInfoStruct
{
DEGREES *result;
DEGREES test;
};struct latlonInfoStruct
{
LAT_DEGREES *lat_result;
LON_DEGREES *lon_result;
LAT_DEGREES lat_test;
LON_DEGREES lon_test;
};struct baroInfoStruct
{
float min;
float max;
float *result;
float test;
};struct strInfoStruct
{
CString min;
CString max;
CString *result;
CString test;
};union EntryInfoUnion
{
floatInfoStruct floatInfo;
intInfoStruct intInfo;
timeInfoStruct timeInfo;
angleInfoStruct angleInfo;
latlonInfoStruct latlonInfo;
baroInfoStruct baroInfo;
strInfoStruct strInfo;
};What does the error message (union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor) trying to tell me. I just don't see the problem with the code snippet. Thanks.
John P.
-
I cannot understand what the problem is with this code and why I get this error: error C2621: union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor
struct floatInfoStruct
{
float min;
float max;
float* result;
float test;
};struct intInfoStruct
{
int min;
int max;
int* result;
int test;
};struct timeInfoStruct
{
SECONDS min;
SECONDS max;
SECONDS *result;
TimeFormats Format;
SECONDS test;
};struct angleInfoStruct
{
DEGREES *result;
DEGREES test;
};struct latlonInfoStruct
{
LAT_DEGREES *lat_result;
LON_DEGREES *lon_result;
LAT_DEGREES lat_test;
LON_DEGREES lon_test;
};struct baroInfoStruct
{
float min;
float max;
float *result;
float test;
};struct strInfoStruct
{
CString min;
CString max;
CString *result;
CString test;
};union EntryInfoUnion
{
floatInfoStruct floatInfo;
intInfoStruct intInfo;
timeInfoStruct timeInfo;
angleInfoStruct angleInfo;
latlonInfoStruct latlonInfo;
baroInfoStruct baroInfo;
strInfoStruct strInfo;
};What does the error message (union 'EntryInfoUnion' : member 'strInfoStruct' has copy constructor) trying to tell me. I just don't see the problem with the code snippet. Thanks.
John P.
jparken wrote:
union EntryInfoUnion { ... strInfoStruct strInfo; };
Union members are not allowed to have (copy) constructors.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
jparken wrote:
union EntryInfoUnion { ... strInfoStruct strInfo; };
Union members are not allowed to have (copy) constructors.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
David, maybe I can't see the forest for the trees. What is the difference between, say, "floatInfoStruct floatInfo;", and "strInfoStruct strInfo;" being part of the union and causing the 'copy constructor' error? Can you explain this in more detail, please? Thank you.
John P.
-
jparken wrote:
union EntryInfoUnion { ... strInfoStruct strInfo; };
Union members are not allowed to have (copy) constructors.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
In other words you can not use a CString in a union since they have copy constructors in them. Try just using a char[] instead.
-
In other words you can not use a CString in a union since they have copy constructors in them. Try just using a char[] instead.
Dustin --- thanks for the response. I just now saw the forest for the trees as you were answering. Sometimes the obvious is too obvious --- like hiding in plain sight. Thanks again.
John P.