[ create a new paste ] login | about

Link: http://codepad.org/pc5PI695    [ raw code | output | fork ]

C++, pasted on Mar 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Vector {
    public:
        union {
            struct {
                float x,y,z;
            } elem;
            float data[3];
        };
};

Vector v;
v.elem.x = 1;
v.elem.y = 2;
v.elem.z = 3;

assert(v.data[0]==1 && v.data[1]==2 && v.data[2]==3);


Output:
1
2
Line 12: error: expected constructor, destructor, or type conversion before '.' token
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: