S
SRK
Hi,
I wanted to use an anonymous union within an structure something like
below -
struct Test
{
union
{
std::string user; //char user[50];
std::string role; //char role[50];
};
std::string desc;
};
Whenever I use, built in data types such as int, char etc, it works
perfectly fine, but for user defined dataypes, it gives me error -
error: member `std::string Test::<anonymous union>::user' with
constructor not allowed in union
error: member `std::string Test::<anonymous union>::user' with
destructor not allowed in union
error: member `std::string Test::<anonymous union>::user' with copy
assignment operator not allowed in union
error: member `std::string Test::<anonymous union>::role' with
constructor not allowed in union
error: member `std::string Test::<anonymous union>::role' with
destructor not allowed in union
error: member `std::string Test::<anonymous union>::role' with copy
assignment operator not allowed in union
Can someone give any idea, how to sort out the problem?
Thanks in advance.
- Shiv Ranjan
(e-mail address removed)
I wanted to use an anonymous union within an structure something like
below -
struct Test
{
union
{
std::string user; //char user[50];
std::string role; //char role[50];
};
std::string desc;
};
Whenever I use, built in data types such as int, char etc, it works
perfectly fine, but for user defined dataypes, it gives me error -
error: member `std::string Test::<anonymous union>::user' with
constructor not allowed in union
error: member `std::string Test::<anonymous union>::user' with
destructor not allowed in union
error: member `std::string Test::<anonymous union>::user' with copy
assignment operator not allowed in union
error: member `std::string Test::<anonymous union>::role' with
constructor not allowed in union
error: member `std::string Test::<anonymous union>::role' with
destructor not allowed in union
error: member `std::string Test::<anonymous union>::role' with copy
assignment operator not allowed in union
Can someone give any idea, how to sort out the problem?
Thanks in advance.
- Shiv Ranjan
(e-mail address removed)