Friend Function in C++

#include<iostream.h>
#include<conio.h>
class A;

class B
{
int b;

public:
B(){b=12;}
void display(A x)
{
	cout<<x.a<<b;             //ERROR: 'a' is not a member of 'A'
}

};

class A
{
int a;

public:
A(){a=10;}
friend void B::display(A);

};

void main()
{
A a1;
B b1;
b1.display(a1);
getch();
}

/END CODE************************/

the above code fetches errror… i have tried passing reference to th friend function but still the problem persists… :frowning: … ANYONE HAS ANY IDEA WHAT CAN I DO… !!!

Well, this code works

[ideone][1]

I just put the function definition for later ( outside the class ) and it worked ( well, it worked on my compiler )

Do not mind the errors on ideone as the code will work on your compiler ( I’m assuming you’re using TurboC++ )
I posted the ideone link because the code seems to be different when I post it directly here ( some strange characters are appearing instead of the code ).

Anyway, you should probably get a new IDE like codeBlocks, the programs you run on your current compiler is not C++ standard ( there is no conio.h in C++ standard, and instead of iostream.h, we use only iostream in the standard ) and will not be accepted on codechef.
[1]: eeGUAc - Online C++ Compiler & Debugging Tool - Ideone.com