#include "iostream"
using namespace std;
class A{
private:
int i;
int a;
int b;
public:
A(int a, int b)
{
this->a = a;
this->b = b;
}
public:
friend void FriendFun(A *fun, int x);
int getA()
{
return this->a;
}
};
void FriendFun(A *fun, int x)
{
fun->a = x;
}
void main()
{
int x;
A a(1, 2);
FriendFun(&a, 3);
cout << a.getA() << endl;
system("pause");
}
c++_友元函数
最新推荐文章于 2022-10-29 21:52:24 发布