Just started programming in c++ again. What does this mean?

I'm confused about this new syntax. Here I have a constructor getting defined but the argument list and the name it seems to be given seem to be bothering me. Can someone give me the correct terms and meaning to this line of code?
1
2
3
Game::Game() : _window(sf::VideoMode(800, 600),"02_Game_Archi"),
_player(150)
{}


so the colon and everything else that follows. like _window and _player.
Last edited on
The colon and the rest are part of an initialization list. http://en.cppreference.com/w/cpp/language/initializer_list

My guess is that the Game class has a member variable called _window and another member variable called _player. Both of those variables are initialized to the values in parenthesis.

The final bracket {} indicates that the constructor has no additional tasks to perform. It set's the member variables and is done.
Last edited on
thanks can the rest of it be defined outside of the declaration inside the class?
You need to have it in one place. If you define the constructor inside the class definition that's were you have to put the initialization list.
Topic archived. No new replies allowed.