[code]class distance
{private: int f ;
float i;
public: distance():f(0),i(0.0)
{}
void get_list()
{ \\geting data from user
}
distance operator+=(distance d)
{
\\containing body of operator
}
}
int main()
{ distance d1,d2,d3;
d1.get_list();
d3=d1+d2;
cout<<"1st distance is: "<<d1<<endl;
cout<<"2nd distance is : "<<d2<<endl;
cout<<"Sum is: "<<d3;
return 0 ;
}
[/code]
Hello! kindly help me in removing this errorm\ its urgent
1) comments are "//", not "\\"
2) you forgot ';' after class definition (Line 16)
3) There is std::distance class, delete usingnamespace std; from your program. (I congrats you, you run into name collision :) )
4) You didn't define operator+ for your class.
first of all the comment line is this // not this \\
the second thing there an error here: distance operator+=(distance d) there is no = in the operation overloading that means it became like this distance operator+(distance d)
the third thing is you forgot the semicolon after the } of the class
and last you cant use the default output operator << with class you have to overloaded it too.
@student 2341:
i dont know wat ur trying to do, if u had gone through the code atleast once, u would have spotted all these errors even with very basic programming knowledge, please try to do things yourself before posting.