1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> using namespace std; class Cents { int m_cents; public: Cents(int cents = 0) { m_cents = cents; } int getcents() const { return m_cents; } friend Cents dcprogramming (const Cents& c1, const Cents& c2) { return (c1.getcents() + c2.getcents()); } }; int main() { } | cs |
여기서 함수 "dcprogramming" 은 클래스 cents의 소속이야?
아니면 클래스 cents를 통해 접근만 할 수 있는 그냥 함수야?
소속 아님 그냥 cents 클래스의 private에 접근할 수 있는 권한을 주는 고임
저 상황에선 friend를 쓸 이유는 없징
c#은 friend 가 없어서 외로워...