Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:44:48+00:00 2026-05-31T01:44:48+00:00

class Game { public: void draw_string(const char *text, int x, int y, TTF_Font *font,

  • 0
class Game {
  public:
    void draw_string(const char *text, int x, int y, TTF_Font *font, SDL_Color color, bool center);

  private:
    void spawn_enemies(vector <Enemy*>& enemies);
};

I have that as the definition of a class, and the definition of spawn_enemies is as follows:

void Game::spawn_enemies(vector <Enemy*>& enemies) {
  if (rand() % difficulty == 0) {
    Enemy *enemy = new Enemy(screen, zombie_image);
    enemies.push_back(enemy);
  }
}

And then I call spawn_enemies:

game.spawn_enemies(enemies);

And I define enemies as:

vector<Enemy*> enemies;

Any idea of why I get this error:

error: no matching function for call to ‘Game::spawn_enemies(std::vector<Enemy*>&)’            
note: candidate is:
note: void Game::spawn_enemies(int)
note:   no known conversion for argument 1 from ‘std::vector<Enemy*>’ to ‘int’
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:44:49+00:00Added an answer on May 31, 2026 at 1:44 am

    I wasn’t doing “using namespace std;” on the header file, so it wasn’t
    including vector, which was causing a lot of weird mistakes

    This is why it is good to use std:: instead of using namespace std.
    It makes your code easier to understand and your code will still compile if they ever add Game or Enemy to the STL (Unlikely, I know). And it would allow you to add your own version of vector, min/max etc. if you really wanted to (I wouldn’t recommend it though).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class with the following declaration of the fields: public class Game
If I have some basic game loop in a thread, like this: public void
I am making a card game in ruby. I have the Game class, which
I renamed the class classBattle to Game and not I get Unable to load
A brief preface: I'm in a game design class where our project for the
My current class is planning on creating a basic networked game, but we have
#admin.py class GameListAdmin(admin.ModelAdmin): list_display = ['game', 'position'] ordering = ('position',) class GameAdmin(admin.ModelAdmin): list_display =
I am making a game for my CS class and the sprites I have
I'm working on a class project to build a little Connect4 game in Java.
I'm creating my first game, and I've currently set up a 'GameState' class, to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.