This question already has an answer here:
- Most vexing parse 1 answer
- Most vexing parse: why doesn't A a(()); work? 5 answers
- Most vexing parse confusion 2 answers
- How is this a most vexing parse? 1 answer
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
{
A(int i)
{
std::cout << "A constructed" << std::endl;
}
};
class B
{
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?
Aucun commentaire:
Enregistrer un commentaire