#include <iostream>
using namespace std;
class B
{
public:
B() {};
B(const B&)
{
cout << "Constructor called for B" << endl;
};
~B() {};
};
struct A
{
B m_oB;
public:
A(B& rB)
{
cout << "test1" << endl;
m_oB = rB;
cout << "test2" << endl;
B oTestB = rB;
};
~A() {};
};
void main()
{
B b;
A a(b);
}
Output:
test1
test2
Constructor called for B
Why was not B::B(const B&) constructor called in test1 case?
PS. I work under MSVC7.0