Answer the question
In order to leave comments, you need to log in
How to make 2 classes friendly to each other (C++)?
Hello. There are two classes. It is necessary to make them friendly TO EACH OTHER.
As I understand it, in order to make class A friendly to class B, the compiler must FULLY see class A, and not just its prototype. But I need to make 2 classes "mutual friendly".
Code model:
class A;
class B
{
friend class A;
private:
int x;
public:
B(int x) {this->x = x;}
}
class A
{
friend class B;
private:
int x;
public:
A(int x) {this->x = x;}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question