Efficient for CPP operator overloading
do not have to access data through accessor and mutator functions
best to make nonmember operator overloads friends
when have to access multi class private variable, otherwise member overloading is better
Friend Class
Entire classes can be friends
Reference
friend 키워드 [friend 전역 함수 , friend 클래스 , friend 멤버 함수]
friend 키워드는 c++에서 지원하는 예외적인 기능의 키워드다. 접근 지정자(Access Modifier)를 완벽히 무시할 수 있는 예외적인 기능을 가졌다. 객체 지향 개념의 정보 은닉(Information Hiding) 개념에 정면으로 위배된다. 기능 및 특징 - private 건 protected건 friend로 선언된 대상에게는 완벽하게 public으로 작용한다. 대상이 외부이건, 상속 관계도에 있건 그런 것은 중요치 않다.
https://genesis8.tistory.com/98
C++ friend 클래스와 함수
안녕하세요 열코입니다.저번시간에 C++ 클래스와 접근제한자에 대해 알아보았는데요.이번에는 저번시간 protected 제한자 부분에서 언급했던 friend(친구) 클래스와 함수에 대해 알아보겠습니다. ☞ freind 클래스란?firend 클래스는 friend로 선언된 다른 클래스의 private 및 protected 멤버에 접근할 수 있습니다.특정 상황에서 클래스 내에 접근하지 못하도록 private 제한을 두었는데, 필요의 경우 해당 클래스나 함수에서접근 가능하도록 사용하는것이 friend 클래스 및 함수입니다.사용법은 friend 키워드를 사용하여 클래스나 함수를 명시 해 주는 것 인데요.아래 예제는 friend 클래스를 지정해주는 예제코드입니다. 123456789101112131415161718192..
https://yeolco.tistory.com/116


Seonglae Cho