老实说,我很尴尬,我不得不问,但我坚持下去。
#include <iostream>
using namespace std;
class Obj
{
};
class Test
{
private:
Obj a;
public:
Test(Obj _a)
: a(_a)
{}
};
int main() {
Obj ob();
Test t(ob);
return 0;
}
我收到此错误:
t.cpp:24: error: no matching function for call to ‘Test::Test(Obj (&)())’
t.cpp:15: note: candidates are: Test::Test(Obj)
t.cpp:10: note: Test::Test(const Test&)
我不明白。相同的片段适用于内置类型(整数和东西)。