rendered paste body#include <stdio.h>#include <math.h>#include <iostream>using namespace std;#define N 3class Vector3f{ public: float polje[N]; Vector3f(); Vector3f(float, float, float); Vector3f(float a[3]); Vector3f(const Vector3f &); Vector3f& operator = (const Vector3f &temp){ if(this != &temp){ this->polje[0] = temp.polje[0]; this->polje[1] = temp.polje[1]; this->polje[2] = temp.polje[2]; } return *this; } //sale = sale + tena //sale += tena Vector3f& operator += (const Vector3f &temp){ this->polje[0] = this->polje[0] + temp.polje[0]; this->polje[1] = this->polje[1] + temp.polje[1]; this->polje[2] = this->polje[2] + temp.polje[2]; return *this; } Vector3f& operator -= (const Vector3f &); Vector3f& operator *= (float temp){ this->polje[0] = this->polje[0] * temp; return *this; } Vector3f& operator + (const Vector3f &temp) const{ // this upucuje na lijevu stranu operatora kojeg preopterecujemo // npr c= a + b, ako preopt +, this upucuje na a; Vector3f rez = *this; // kopiramo a u rez; rez += temp; // koristimo vec preoptereceni operator += return rez; } bool operator== (const Vector3f &temp) const{ bool nest; if ( this->polje[0] == temp.polje[0] && this->polje[1] == temp.polje[1] && this->polje[2] == temp.polje[2] ) nest = 1; else nest = 0; return nest; } bool operator !=(const Vector3f &temp) const{ bool nest; if (*this == temp) nest=0; else nest=1; return nest; } float& operator[](unsigned int temp){ return this->polje[temp]; } Vector3f& vec_produkt(Vector3f& temp){ Vector3f rez; rez.polje[0] = this->polje[1] * temp.polje[2] - temp.polje[1] * this->polje[2]; rez.polje[1] = this->polje[0] * temp.polje[2] - temp.polje[0] * this->polje[2]; rez.polje[2] = this->polje[0] * temp.polje[1] - temp.polje[0] * this->polje[1]; rez.ispisi(); return rez; } void ispisi();};int main(){ Vector3f prvi; prvi.ispisi(); Vector3f drugi(1,2,3); drugi.ispisi(); Vector3f treci(prvi); treci.ispisi(); float b[3]{7,8,9}; Vector3f tena(b); tena.ispisi(); Vector3f sale(2,3,4); sale.ispisi(); sale += tena; sale *= 5; cout << "sale " << endl; sale.ispisi(); Vector3f beba; beba = sale + tena; beba.ispisi(); beba = sale; if (beba != sale) cout << "da" << endl; else cout << "ne " << endl; cout << beba[2] << endl; Vector3f jedan(1,1,1); Vector3f produkt; produkt = jedan.vec_produkt(drugi); produkt.ispisi(); return 0;}Vector3f::Vector3f(){ for( int i=0; i<3; i++){ polje[i]=0; }}void Vector3f::ispisi(){ cout << "Vector3f: " << endl; for( int i=0; i<3; i++){ cout << polje[i] << "\t"; } cout << endl;}Vector3f::Vector3f(float x,float y,float z){ polje[0]=x; polje[1]=y; polje[2]=z;}Vector3f::Vector3f(const Vector3f &temp){ for( int i=0; i<3; i++){ polje[i] = temp.polje[i]; }}Vector3f::Vector3f(float a[3]){ for( int i=0; i<3; i++) polje[i]=a[i];}