I wonder why the constructor doesn't work/get called in the first case.
#include <iostream>
#include <typeinfo>
class Test{
public:
Test(){ std::cout << "1\n"; };
Test(int){ std::cout << "2\n"; };
};
int main()
{
Test a(); // actually doesn't call the constructor
Test b(1); // "2"
std::cout << (typeid(b).name()) << std::endl; // "4Test"
std::cout << (typeid(a).name()); // "F4TestvE"
return 0;
}
I've also found that typenames of created variables are strange. Can anybody explain such a behavior?
I use mingw gcc 4.7.2 for Windows to compile my projects
Thanks a lot.