"no overloaded function takes 0 arguments" when trying to insert into std :: vector

1

bunny is the default class that has only bunny(construtor) and ~bunny(desconstrutor) default.

int main()
    {
        vector<bunny> bunnies; // Este usa o construtor padrão.
        bunnies.push_back(); // ERRO! este não pode usar.

        system("Pause");

        return 0;
    }
  

Error C2661 'std::vector<bunny,std::allocator<_Ty>>::push_back': no overloaded function takes 0 arguments.

    
asked by anonymous 02.06.2016 / 19:44

1 answer

3

The problem is just that you are trying to add something to the vector without saying what. You need to pass an object of type bunny to the method for it to do the addition:

bunnies.push_back(bunny());

See working on ideone and on CodingGround .

    
02.06.2016 / 20:48