Skip to content

Instantly share code, notes, and snippets.

@lucasdemarchi
Created January 1, 2016 21:47
Show Gist options
  • Save lucasdemarchi/e09639f8c1bd8152b505 to your computer and use it in GitHub Desktop.
Save lucasdemarchi/e09639f8c1bd8152b505 to your computer and use it in GitHub Desktop.
#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