Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

anonymous union with an anonymous struct

$
0
0

Hello,
this is my compiler's information:
ICPC Intel(R) 64, Version 14.0.2.144 Build 20140120

the source code example is not intricacy:

struct vect3{
        int x,y,z;
        vect3(int _x,int _y,int _z):x(_x),y(_y),z(_z){ }
};
class vect
{
        union{
                int leaf[9];
                struct{
                        vect3 a;
                        vect3 b;
                        vect3 c;
                };
        };
public:
        vect(int _a,int _b,int _c):a(_a,_b,_c),b(_a,_b,_c),c(_a,_b,_c){  }
        vect3 getXcoordinate(){return a;}
        vect3 getYcoordinate(){return b;}
        vect3 getZcoordinate(){return c;}
};
int main()
{
        vect v1=vect(1,2,3);
        std::cout<<"X is: "<<v1.getXcoordinate().x<<"\tY is: "<<v1.getYcoordinate().y<<std::endl;
        return 0;
}

this code can be compiled by visual studio 2008' s compiler.

but, icpc reports: invalid member for anonymous member class -- class "vect3" has a disallowed member function  vect3 a;

I know the error comes from the anonymous struct in an anonymous union. But i just want to use it in that way. How can I do ?


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>