#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
class A {
public:
A(int a) {
this->a = a;
}
void printA() {
cout << "a=" << this->a << endl;
}
friend class B;
private:
int a;
};
class B {
public:
B(int b) {
this->b = b;
}
void printB() {
A objA(101);
cout << "objA=" << objA.a << endl;
cout << "b=" << this->b << endl;
}
private:
int b;
};
int main()
{
A t1(45);
t1.printA();
B t2(200);
t2.printB();
return 0;
}
结果: