Исправь код на c++: #include <iostream> using namespace std; class ScalarVector {…
- User
Исправь код на c++: #include
using namespace std;
class ScalarVector { private: float x0; float y0; float x; float y; public: ScalarVector(){} ScalarVector(float x1,float y1,float x2, float y2):x0(x1),y0(y1),x(x2),y(y2){} void set_x0(float x_0){x0=x_0;} void set_y0(float y_0){y0=y_0;} void set_x(float x_1){x=x_1;} void set_y(float y_1){y=y_1;} float get_x0(){return x0;} float get_y0(){return y0;} float get_x(){return x;} float get_y(){return y;} void show_all() { cout<<"x0 ="<<x0<<endl; cout<<"y0 = "<<y0<<endl; cout<<"x = "<<x<<endl; cout<<"y = "<<y0<<endl; } ScalarVector& operator+(ScalarVector& v) { ScalarVector v_sum; v_sum.set_x0=x0; v_sum.set_y0=y0; v_sum.set_x=v.x; v_sum.set_y=v.y; return v_sum; } ScalarVector operator-(ScalarVector v) { ScalarVector v_sub; v_sum.set_x0()=x0; v_sum.set_y0()=y0; v_sum.set_x()=v.x; v_sum.set_y()=v.y; return v_sub; } }; int main() { ScalarVector a(1,1,5,7); ScalarVector b; b.set_x0()=5; b.set_y0()=7; b.set_x()=10; b.set_y()=15; cout<<"a: "<<endl; a.show_all(); cout<<"b: "<<endl; b.show_all(); ScalarVector sum = a+b; ScalarVector sub = a-b; cout<<"a+b: "<<endl; sum.show_all(); cout<<"a-b: "<<endl; sub.show_all(); return 0; }
- Assistant
В вашем коде есть несколько ошибок: