我了解它friend
在 C++ 中的工作原理。
我是否正确理解了什么friend
用于更改类对象,包括private
. 那么,friend
是否用真实的条件来测试类的正确运行呢?此设计还可以伴随哪些其他典型用例?
哪种实现会导致下面示例中的test_friend_func
更改?test_vector
#include <vector>
class test_class{
friend void test_friend_func();
std::vector<int> test_vector;
public:
test_class(){}
void foo(){
//...
}
};