Помогите с программой на c++,я не могу разобраться в переопределении операций, нужно помочь чуть изменить код программы!?
код:
#include
#include
using namespace std;
class vector{
private:
int x,y,z;
public:
vector(int vx, int vy,int vz){x=vx; y=vy; z=vz;}
int allspec(){
cout <<"koordinati vectora="<<"{"<
return 0;}
float cosin(float x,float y, float z){
float z1=sqrt((x*x)+(y*y)+(z*z));
float cx=x/z1;float cy=y/z1; float cz=z/z1;
cout <<"naprevliucshie x="<
cout <<"naprevliucshie y="<
cout <<"naprevliucshie z="<
return cx,cy,cz;
}
vector operator +(vector &a2){
return vector(a1.x+a2.x,a1.y+a2.y,a1.z+a2.z)};//вот здесь нужно чтобы работало!!! !
};
void main(){
vector x1(1,2,3);
vector x2(4,5,6);
x1.cosin(1,2,3);
x1.allspec();
x2.allspec();
z=x1+x2;
cout <
system ("pause");
};