请问一下我哪部错了,c++

c++的友元函数部分,求大佬帮忙

img

img

太多错误了,友元函数不能是另一个类的成员函数。修改成为友元类,修改如下你自己看吧!有帮助请采纳谢谢!

#include<iostream>
using namespace std;
class B;
class A
{
private:
    int a;
    int b;
public:
    A(int m, int n) : a(m), b(n) {}
    void getAB(const B& p);
};

class B
{
private:
    int c;
    int d;
public:
    B(int m, int n) :c(m), d(n) {}
    friend class A;
};

void A::getAB(const B&p)
{
    cout << a << b << p.c << p.d << endl;
}

img