#include<iostream>
using namespace std;
class A
{
friend class B;
private:
int m_a;
public:
A(int a)
{
m_a=a;
}
};
class B
{
private:
int m_b;
public:
B(int b)
{
m_b=b;
}
void print();
};
void B::print()
{
A a(2);
cout<<a.m_a<<endl;
}
int main()
{
B b(1);
b.print();
return 0;
}
c++中友元类的使用
猜你喜欢
转载自blog.csdn.net/sinat_42721727/article/details/81240192
今日推荐
周排行