Opened 18 years ago
Closed 18 years ago
#291 deleted Support Requests (None)
with constructor not allowed in union
| Reported by: | nobody | Owned by: | nobody | 
|---|---|---|---|
| Milestone: | Component: | None | |
| Version: | None | Severity: | |
| Keywords: | Cc: | 
Description
I get error - with '..' constructor not allowed in
union, when I compile the following code in gcc. Any
method for overcoming this kind of problem.
The code is like this.
 Struct X {
     union ut1 {
        struct st1 { 
            int i1;
            long l1;
        } s1;
        struct st2 {
            char c1;
            double d1;
        } s2;
        X() {}         // g++ gives error if
constructor is present.
};
Struct Y {
     int i;
     union ut3 {
         X x;    // member 'X Y::ut3::x' with constructor
                  // not allowed in union.
         int i1;
     } u3;
     Y () { i = 0; }
};
int main() 
{ 
    Y y;
}
      
  Note:
 See   TracTickets
 for help on using tickets.
    
