Vector member function

Run Settings
LanguageC++
Language Version
Run Command
#include <stdio.h> #include <math.h> float v2Length(float x,float y) { return sqrt(x*x+y*y); } struct v2 { union { struct { float x; float y; }; float e[2]; }; float Length() { return v2Length(x,y); }; }; float v2Length(v2 a) { return v2Length(a.x,a.y); } int main() { printf("%f\n", v2Length(8,6) ); printf("%f\n", v2Length(v2{8,6}) ); printf("%f\n", v2{8,6}.Length() ); // Is this a gain??? return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines