class vector2{ float x; float y; constructor( float x, float y ) { //printf("constructor has been called.. x: %i, y: %i \n", x, y); this->x = x; this->y = y; // this causes an infinity loop. // vector2 a = new vector2( 0, 0 ); // this->add( &a ); } vector2 * operator+( vector2 * b ){ this->add( b ); return this; } vector2 * operator+=( struct vector2 * b ) { // not proper //strcat( this, b ); //printf("operator += triggered"); return b; } add( vector2 * a ) { this->x += a->x; this->y += a->y; } subtract( vector2 * a ) { this->x -= a->x; this->y -= a->y; } int length() { return this->x + this->y; } }