Search code examples
c++default-constructor

error C2512: 'Tile' : no appropriate default constructor available


Still have the error even with a default constructor.

class Foo {
    public:
    Foo ( int x, int y, int type );
}

And in the .cpp file

Foo::Foo ( int x = 0, int y = 0, int type = 0 ) {

And yet, when I call it

Foo foo_array[5][5];

I get the error. Any reason why that may be?


Solution

  • Put the default arguments in the declaration of constructor. As it is, the compiler doesn't know about them when you try to create the array.