I am wondering how come this code correct and how the compiler knows to first create an obj of class A, I would think it shouldn't compile since B's ctor request an argument of type A not int
class A
{
int a1;
public:
A(int i) { cout << i << "A"<<endl;}
friend class B;
};
class B
{
public:
B(A a) {cout <<"B" <<a.a1;}
};
void main()
{
B b(7);
}
output: 7A B7