class B should define before class A, and class A is class B's firend class, so you should define "class A;" before class B.
Like this:
#include <iostream>
using namespace std;
class A;
class B
{
int valueb;
public:
B() { }
B(int x) { valueb = x; }
friend A;
};
class A
{
int valuea;
public:
A() {}
A(int x) { valuea = x; }
void convert(B x)
{
valuea = x.valueb;
}
int getValue() { return valuea; }
};
int main()
{
A a(1);
B b(2);
a.convert(b);
cout << a.getValue() << endl;
}