
[C++] friend 키워드
friend 키워드 friend 기능 * 접근지정자를 무효할 수 있는 예외적인 기능을 제공한다. 외부에서 private, protected 멤버를 접근할 수 있다. * 클래스 선언에서 외부 클래스나 함수를 friend로 명시하면, private나 protected 멤버 변수, 함수를 public처럼 접근할 수 있다. * 자바에서 같은 package안에 있는 디폴드 접근지정자와 기능이 비슷하다. friend 선언 // 외부 함수 선언 class Vector { public: friend void print_vector(Vector* vector); Vector(int x, int y) { mX = x; mY = y; } private: int mX; int mY; }; void print_vector(Ve..