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

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-05-05T19:53:33Z Indexed on 2010/05/05 19:58 UTC
Read the original article Hit count: 252

Filed under:
|
|
|
|
class Foo
{
public:
    explicit Foo() {}
    explicit Foo(Foo&) {}
};

Foo d = Foo();

error: no matching function for call to 'Foo::Foo(Foo)'

I tried changing Foo(Foo&) to Foo(Foo) as the error suggests, which AFAIK is not a valid constructor, and sure enough I get:

error: invalid constructor; you probably meant ‘Foo (const Foo&)’

What gives? How do I resolve this? (This is on GCC by the way)

© Stack Overflow or respective owner

Related posts about gcc

Related posts about error