struct A{
A(){}
};
struct B{
B(const A& a){}
};
int main()
{
//Originally I would like to write down below code
A a;
B b(a);
//Unfortunately I end up with below code by accident and there is no compile error
//I have figured out the below does not create temporary A and call B constructor to
//create B as the above codes,
//it declares a function with return value B, name b,
//and some input parameter, my question is 1) what the input parameter is ?
//2) How to implement such a function.
B b(A()); // There is no global function A() in my test case.
}
질문은 의견에 일부 사람들이 나를 이해하는 데 도움이되기를 바랍니다. 고맙습니다.클래스 생성자가있는 함수를 함수 매개 변수로 선언하십시오.
관련 : 가장 성가신 파싱 (http://en.wikipedia.org/wiki/Most_vexing_parse). – dasblinkenlight