gpt4 book ai didi

c++ - 在类名之后但在开括号之前的引号

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:00:37 24 4
gpt4 key购买 nike

<分区>

我有一个我想不通的简单问题。我没有写这段代码。我知道 tetromino_ 和 moveTime_ 是两个不同类的实例。我的问题是为什么他们在括号外声明但仍在类(class)内。这个实例声明方法有名字吗?

Game::Game() :
tetromino_{ static_cast <Tetromino::Type>(rand() % 7) },
moveTime_{ SDL_GetTicks() }
{
//srand(time(NULL));
//initialize SDL and if it fails, present an error
if (SDL_Init(SDL_INIT_VIDEO) != 0){
throw std::runtime_error("_Init(SDL_INIT_VIDEO)");
}
//width of thhe window is 650/2 and the height is 650
SDL_CreateWindowAndRenderer(650 / 2, 650, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS, &window_, &renderer_);
//set the window position
SDL_SetWindowPosition(window_, 365, 1);
}

如果我的问题不清楚,这叫什么

Game::Game() :
tetromino_{ static_cast <Tetromino::Type>(rand() % 7) },
moveTime_{ SDL_GetTicks() }
{

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com