主函数中用<<>时
出现错误
no operator defined which takes a right-hand operand of type 'class vsctor' (or there is no acceptable conversion)
#include
using namespace std;
class vsctor
{
public:
vsctor(int z1=0,int z2=0,int z3=0);
void set(int z1,int z2,int z3);
void get(int& a,int& b,int& c) const;
//ostream& operator<<(ostream& os,const vsctor& v);
//istream& operator>>(istream& is,vsctor& v);
private:
int a,b,c;
};
main()
{
int z1,z2,z3,x1,x2,x3,y1,y2,y3;
vsctor v1(1,1,1);
vsctor v2(2,2,2);
cout<
vsctor v;
cin>>v;
cout<
}
vsctor::vsctor(int z1,int z2,int z3):a(z1),b(z2),c(z3)
{}
void vsctor::set(int x1,int x2,int x3)
{
a=x1;b=x2;c=x3;
}
void vsctor::get(int& z1,int& z2,int& z3) const
{
z1=a;z2=b;z3=c;
}
ostream& operator
{
int z1,z2,z3;
v.get(
z1,z2,z3);
os
return os;
}
istream& operator>>(istream& is,vsctor& v)
{
int z1,z2,z3;
is>>z1>>z2>>z3;
v.set(z1,z2,z3);
return is;
}