伪代码可以解释你的意图,但它不能解释你的错误,因为它不会以你描述的方式出错:
class foo {
type arg1, arg2;
foo (type _arg1, type _arg2) {
_arg1=arg1;
_arg2=arg2;
}
}
class foo2 {
foo member;
foo2(type _arg1, type _arg2) {
member(_arg1, _arg2);
}
}
尽管它确实产生了有用的诊断:
gcc -Wall junk.cc
junk.cc: In constructor ‘foo2::foo2(int, int)’:
junk.cc:12:32: error: no matching function for call to ‘foo::foo()’
junk.cc:3:5: note: candidates are: foo::foo(int, int)
junk.cc:1:11: note: foo::foo(const foo&)
junk.cc:13:28: error: no match for call to ‘(foo) (int&, int&)’
junk.cc: At global scope:
junk.cc:14:5: error: expected unqualified-id at end of input
这表明您不应该在这里发布“类似”的代码并期待有用的答案。