cpp_friend - 8BitsCoding/RobotMentor GitHub Wiki
friendλ μν... μ΅λν μ°μ§λ§μ
friend μ¬μ©
// X.h
class X {
friend class Y;
private:
int mPrivateInt;
};
// Y.h
#include "x.h"
class Y {
public:
void Foo(X& x) {x.mPrivateInt += 10;}
};
μ μ ν¨μμμ friend μ¬μ©νκΈ°
// X.h
class X {
friend void Foo(X& x);
private:
int mPrivateInt;
};
// Global
void Foo(X& x)