Hi All,
Could someone please tell me why this code does not compile.
struct A {};
struct B {
B(A &) {}
};
struct C {
C(B &) {}
void f() {}
};
void foo() {
A a;
C c(B(a));
c.f();
}
If I change foo() to the following then it does compile:
void foo() {
A a;
B b(a);
C c(b);
c.f();
}
I would have thought that you could pass the B temporary into C's
constructor like that?
Andy
Could someone please tell me why this code does not compile.
struct A {};
struct B {
B(A &) {}
};
struct C {
C(B &) {}
void f() {}
};
void foo() {
A a;
C c(B(a));
c.f();
}
If I change foo() to the following then it does compile:
void foo() {
A a;
B b(a);
C c(b);
c.f();
}
I would have thought that you could pass the B temporary into C's
constructor like that?
Andy
Comment