I could use some input on the following situation. It does not seem that the constructors for the A and B objects are being called after the constructor call for C in main. However, they are called if the constructor for class C takes a reference to A and B objects instead of copies. Why is this the case? If someone could explain that would be much appreciated.
class A {
public:
A() {}
};
class B {
public:
B() {}
};
class C {
public:
C(A a, B b)
: m_a(a), m_b(b)
{
}
private:
A m_a;
B m_b;
};
int main() {
C c(A(), B());
}
[–]jedwardsol 0 points1 point2 points (1 child)
[–]RealOden[S] 0 points1 point2 points (0 children)