I am still confused with the CTORs:
Question 1:
why line 15 call A:A(int) instead of A:A(double&)?
Question 2:
why line 18 did not call A:A(B&)?
#include <iostream> using namespace std; class B{}; class A{ public: A(int ) {cout<<"A::A(int)"<<endl;} A(double&){cout<<"A::A(double&)"<<endl;} // it will work if it is A(double), without the & A(B&){cout<<"A::A(B&)"<<endl;} }; int main() { /*line 15*/ A obj((double)2.1); // this will call A(int), why? B obj2; A obj3(obj2); /*line 18*/ A obj4(B); // this did not trigger any output why? }
-Werror.)A x(int);... something new every day:-)A x(int);.A x(int());...