#include<iostream>
#include<ctime>
using namespace std;
class Person
{
//声明友元函数
friend void test02();
public:
string P_name;
private:
string P_sex;
};
void test02()
{
Person p1;
p1.P_sex = "man";
cout << p1.P_sex << endl;
}
int main()
{
test02();
return 0;
}
C++友元函数
最新推荐文章于 2024-11-09 20:38:27 发布