class test{
public:
explicit test(){}
};
int main(){
test t1;
test t2(t1);
return 0;
}
Why is the above snippet compiling? the constructor test()
does not take any inputs, it's even coded as such explicitly. However test t2(t1);
seems to compile?
Edit
Is the auto generated constructor there to support casts such as this?
class test{
public:
test(int in){}
// test(test& in){}
};
void call(test in){}
int main(){
test t1(5);
call(test(t1));
return 0;
}
test(t1)
is technically a cast which could call the class constructor.