0

hi, i have an error in my syntax where define operator +() . compiler says "declaration syntax error" i have. what is my fault!?

#include<iostream.h>
class exforsys{
private:
int x,y;
public:
exforsys(){x=0; y=0;}
void getvalue(){
cout<<"\n enter value for x:";
cin>>x;
cout<<"\n enter value for y:";
cin>>y;
}
void displayvalue(){
cout<<"value of x is:"<<"value of y is:"<<y; }
exforsys operator + (exforsys);
}
exforsys exforsys :: operator +(exforsys e2){
int x1=x+e2.x;
int y1=y+e2.y;
return exforsys(x1,y1);
}
void main(){
exforsys e1,e2,e3;
cout<<"enter value for object e1:";
e1.getvalue();
cout<<"enter value for object e2:";
e2.getvalue();
e3=e2+e1;
}

Edited by aliirooni: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Salem
0

tnx man. i correct that to this:

.
.
.
exforsys(int x,int y){x=0; y=0;}
.
.
.
};
.
.
.

but it says:
"could not not find a match for exforsys::exforsys"
for the line after main function starts.

Edited by aliirooni: n/a

1

Are you trying to make me believe you got the ; in the right place?

The only thing I would do with that code is press CTRL-A then press DEL.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.