In the following code, I have two parametrizes constructors. I have compiled and run into Gcc compiler but constructors not called.
#include <iostream>
class A
{
public:
A(int i)
{
std::cout << "A constructed" << std::endl;
}
};
class B
{
public:
B(A a1)
{
std::cout << "B constructed" << std::endl;
}
};
int main()
{
int i = 5;
B b1(A(i));
std::cout << i << std::endl;
return 0;
}
Output:
5
So, Why constructors not called?