Troubleshooting: error C2079: uses undefined class in friend function

Опубликовано: 18 Октябрь 2024
на канале: Improve Your Programming skills
401
2

When using friend function, you may got an error code c2079 : uses undefined class. This video helps you to solve the problem
My program has:
a class A containing a private member named a
a class B containing a test() method. This B::test() method wants to
access a private member of class A.
class A {
private:
int a;
friend void B::test();
};
class B {
public:
//this method wants to access private member of class A
void test();
};