Friend class (Lớp bạn)

Friend class trong C++ có thể truy cập bởi các bộ phận "private" và "protected" của [class], trong đó nó được khai báo như một friend. Trong khai báo friend class tất cả các bộ phận chức năng của friend class trở thành friend của class trong đó friend class đã được khai báo. Trường hợp friend không được kế thừa, mỗi friend phải được khai báo một cách rõ ràng. Các friend class có thể giúp cải thiện việc đóng gói nếu sử dụng chúng một cách khôn ngoan.

By English

A friend class in C++, can access the "private" and "protected" members of the class in which it is declared as a friend. On declaration of friend class all member function of the friend class become friends of the class in which the friend class was declared. Friend status is not inherited; every friendship has to be explicitly declared. Friend classes can help in improving Encapsulation if used wisely.A friend class in C++, can access the "private" and "protected" members of the class in which it is declared as a friend. On declaration of friend class all member function of the friend class become friends of the class in which the friend class was declared. Friend status is not inherited; every friendship has to be explicitly declared. Friend classes can help in improving Encapsulation if used wisely.

Like Doanh nhân số