L
Lotti
Народ! Здесь в головной программе даже тупо строку не выводит! Чтто за лажа такая, я вообще не догоняю!! Может объясните?
#include <iostream>
#include <stdio.h>
using namespace std;
class vector
{
private:
double x;
double y;
double z;
public:
vector(){x=y=z=0.0;}
vector (double x1){x=x1; y=z=0.0;}
vector (double x1,double y1){x=x1;y=y1;z=0.0;}
vector (double x1,double y1,double z1){x=x1;y=y1;z=z1;}
double get_x () const { return x;}
double get_y () const { return y;}
double get_z () const { return z;}
void set_x (double x1);
void set_y (double y1);
void set_z (double z1);
vector operator + ( vector &v1);
vector operator + ( const double a) const;
vector operator - ( vector &v1);
vector operator - ( const double a) const;
double operator * ( const vector &v1) const;
vector operator = ( vector & v1);
bool operator == ( const vector &v1) const;
void coutv () const;
};
void vector:: set_x (double x1)
{
x=x1;
}
void vector:: set_y (double y1)
{
y=y1;
}
void vector:: set_z(double z1)
{
z=z1;
}
vector vector:: operator +( vector &v1)
{
x=x +v1.x;
y= y+v1.y;
z=z+v1.z;
}
vector vector:: operator -( vector &v1)
{
x=x-v1.x;
y=y-v1.y;
z=z-v1.z;
}
double vector:: operator *(const vector &v1) const
{
return x*v1.x+y*v1.y+z*v1.z;
}
vector vector:: operator =(vector &v1)
{
x=v1.x;
y=v1.y;
z=v1.z;
}
bool vector:: operator == ( const vector &v1) const
{
if ((x==v1.x)&&(y==v1.y)&&(z==v1.z))
return true;
else return false;
}
void vector:: coutv () const
{
cout<<"x="<<get_x()<<" y="<<y<<" z="<<z<<endl;
}
int main ()
{
vector v1, v2(1),v3(1,2), v4(1,2,3);
v1.coutv();
v2.coutv() ;
v3.coutv() ;
v4.coutv ();
v1.set_x(5.0);
cout<<"aaaa\n";
cout<<"x="<<v1.get_x();
}
#include <iostream>
#include <stdio.h>
using namespace std;
class vector
{
private:
double x;
double y;
double z;
public:
vector(){x=y=z=0.0;}
vector (double x1){x=x1; y=z=0.0;}
vector (double x1,double y1){x=x1;y=y1;z=0.0;}
vector (double x1,double y1,double z1){x=x1;y=y1;z=z1;}
double get_x () const { return x;}
double get_y () const { return y;}
double get_z () const { return z;}
void set_x (double x1);
void set_y (double y1);
void set_z (double z1);
vector operator + ( vector &v1);
vector operator + ( const double a) const;
vector operator - ( vector &v1);
vector operator - ( const double a) const;
double operator * ( const vector &v1) const;
vector operator = ( vector & v1);
bool operator == ( const vector &v1) const;
void coutv () const;
};
void vector:: set_x (double x1)
{
x=x1;
}
void vector:: set_y (double y1)
{
y=y1;
}
void vector:: set_z(double z1)
{
z=z1;
}
vector vector:: operator +( vector &v1)
{
x=x +v1.x;
y= y+v1.y;
z=z+v1.z;
}
vector vector:: operator -( vector &v1)
{
x=x-v1.x;
y=y-v1.y;
z=z-v1.z;
}
double vector:: operator *(const vector &v1) const
{
return x*v1.x+y*v1.y+z*v1.z;
}
vector vector:: operator =(vector &v1)
{
x=v1.x;
y=v1.y;
z=v1.z;
}
bool vector:: operator == ( const vector &v1) const
{
if ((x==v1.x)&&(y==v1.y)&&(z==v1.z))
return true;
else return false;
}
void vector:: coutv () const
{
cout<<"x="<<get_x()<<" y="<<y<<" z="<<z<<endl;
}
int main ()
{
vector v1, v2(1),v3(1,2), v4(1,2,3);
v1.coutv();
v2.coutv() ;
v3.coutv() ;
v4.coutv ();
v1.set_x(5.0);
cout<<"aaaa\n";
cout<<"x="<<v1.get_x();
}