I have a simple question that I cannot understand. I did not write this code. I know that tetromino_ and moveTime_ are instances of two different classes. My question is: why are they declared outside the brackets, but still in the class. Does this instance declaration method have a name?
Game::Game() :
tetromino_{ static_cast <Tetromino::Type>(rand() % 7) },
moveTime_{ SDL_GetTicks() }
{
if (SDL_Init(SDL_INIT_VIDEO) != 0){
throw std::runtime_error("_Init(SDL_INIT_VIDEO)");
}
SDL_CreateWindowAndRenderer(650 / 2, 650, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS, &window_, &renderer_);
SDL_SetWindowPosition(window_, 365, 1);
}
If my question was not clear what this is called
Game::Game() :
tetromino_{ static_cast <Tetromino::Type>(rand() % 7) },
moveTime_{ SDL_GetTicks() }
{
source
share