#include <iostream>
using namespace std;
class vecto{
private:
int x,y;
public:
vecto(){
x=0;
y=0;
}
vecto(int i,int j){
x=i;
y=j;
}
// void show(){
// cout<<"("<<x<<","<<y<<")"<<endl;
// }
vecto operator + (vecto const& b);
friend vecto operator-(vecto const&b,vecto const&c);
friend istream& operator>> (istream& s,vecto& f);
friend ostream& operator<< (ostream& s,const vecto& f);
};
vecto vecto::operator+(vecto const& b){
vecto t;
t.x=x+b.x;
t.y=y+b.y;
return t;
}
vecto operator - (vecto const&b,vecto const&c){
vecto a;
a.x=b.x-c.x;
a.y=b.y-c.y;
return a;
}
istream& operator>> (istream& s,vecto& f){
cout<<"\nnhap x:";s>>f.x;
cout<<"\nnhap y:";s>>f.y;
return s;
}
ostream& operator>> (ostream& s,const vecto& f){
s<<"("<<f.x<<","<<f.y<<")"<<endl;
return s;
}
int main()
{
vecto d,b,c;
cout<<"nhap vao 2 toa do bat ki:";
cin>>b,c;
d=b+c;
cout<<"Tong 2 toa do:"<<d;
d=b-c;
cout<<"\nHieu 2 toa do:"<<d;
return 0;
}
Anh chị chỉ giáo giúp em, em đã làm y như demo nhưng nó cứ bị lỗi ở phần khai báo class với phần xuất :<


83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?