标签:nbsp space code main names private iostream int std
//关于友元:可以自由取得friend中private成员 //相同class的各object互为友元 #include <iostream> using namespace std; class complex{ public: complex(int r=0,int i=0) :re(r),im(i){ } int func(const complex& friends) { return friends.re+friends.im; } private: int re,im; }; int main() { complex c1(3,4); complex c2; cout<<c2.func(c1)<<endl; return 0; }
标签:nbsp space code main names private iostream int std
原文地址:https://www.cnblogs.com/zmachine/p/12239781.html