Foo f = Foo(); // no matching function for call to 'Foo::Foo(Foo)' … huh?

后端 未结 10 2522
小鲜肉
小鲜肉 2021-02-19 20:13
class Foo
{
public:
    explicit Foo() {}
    explicit Foo(Foo&) {}
};

Foo d = Foo();

error: no matching function for call to \

10条回答
  •  迷失自我
    2021-02-19 20:43

    Foo d = Foo();
    

    should be

    Foo d;
    

    The first line creates a Foo instance and then copies it to d;

提交回复
热议问题