I am learning C++ using the book "C++ Primer", and write some small code to test the concepts I am learning.

According to the book, a friend a class can be:
(1) a non-member function
(2) a member function of another class
(3) another class

I am testing how to write a friend of class A , which is a member function of class B. Below is my code:

Code:
class A;

class B{
public:
	int getValue(A* pa) {
		return pa->va_;
	}
};

class A {
friend int B::getValue(A* pa);
public:
	A():va_(1){}
private:
	int va_;
};
I always got the error of: error C2027: use of undefined type 'A'

I used forward declaration of class A, and pointer to A in class B, why this does not work?

Thanks a lot for answering a newbie's question.