/*
* ccb.cpp
*
* Created on: 2024-6-7
* Author: root
*/
#include
using std::cout;
using std::endl;
class Class1;
class Class2;
class Class1
{
friend class Class2;
public:
void Class();
private:
int a;
};
void Class1::Class()
{
a=1234;
}
class Class2
{
public:
void CopyC1toC2(Class1 &c1);
int a;
};
void Class2::CopyC1toC2(Class1 &c1)
{
a=c1.a;
}
int main()
{
Class1 c1;
Class2 c2;
c2.CopyC1toC2(c1);
cout << c2.a << endl;
return 0;
}
运行:
文章评论(0条评论)
登录后参与讨论