Created
January 1, 2016 21:47
-
-
Save lucasdemarchi/e09639f8c1bd8152b505 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
class Vector { | |
float x = 0, y = 0, z = 0; | |
public: | |
Vector() { } | |
void set_x(float x) { this->x = x; } | |
}; | |
struct Vector_s { | |
float x, y, z; | |
}; | |
union bla { | |
Vector v; | |
struct Vector_s s; | |
bla() : v() { } | |
}; | |
int main(void) | |
{ | |
union bla bla; | |
bla.v.set_x(20.0); | |
printf("%.1f\n", bla.s.x); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment