Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   question about function friend(help) (http://www.go4expert.com/forums/question-function-friend-help-t24348/)

godofwar47 3Jan2011 02:00

question about function friend(help)
hi guys .i am beginner .plz tell me why is my program problem?plz write answer my question.tnx

#include <iostream>
using namespace std;
class test1{
int x;
int y;
void set_xy(int i,int j){x=i;y=j;}
 friend int equal (test1 t1 ,test2 t2);
class test2 {
int x;
int y;
void set_xy (int i,int j) {x=i;y=j;}
friend int equal (test1 t1,test2 t2);
int equal(test1 t1,test2 t2);
{if (t1.x==t2.x  &&  t1.y==t2.y)
return 1;
return 0;}
int main()
test1 t1;
test2 t2;
if (equal(t1,t2))
cout<<"t1 and t2 are equal"<<endl;
return 0;


shabbir 3Jan2011 11:26

Re: question about function friend(help)
You had the same thread 2 more times which I have deleted and avoid doing that.

xpi0t0s 3Jan2011 18:56

Re: question about function friend(help)
The semicolon after equal() completes the definition of a prototype, so the code afterwards is incorrect because there's no function header. Remove the semicolon and that should fix the problem.

All times are GMT +5.5. The time now is 15:49.