main.cpp:561:80: error: request for member ‘c_str’ in ‘str’, which is of non-class type ‘std::string [10] {aka std::basic_string<char> [10]}’
displayFont.showHighscore[i] = TTF_RenderText_Solid(displayFont.menuFont,str.c_str(), displayFont.colorText);
大家好!
根据这个函数,这显示了从成员类中检索到的数据的排名。这也使用了另一个类(displayFont)的ttf内容。当我编译这个时,说一个错误。我留下代码:
void showHighscore() {
displayFont.menuFont = TTF_OpenFont("fonts/Lanehum.ttf",25);
displayFont.colorText = { 255, 255, 255 }; // Add content
stringstream texting[10]; // Variables
string str[10];
SDL_Rect posHighscore[10];
for (int i = 0; i < 10; i++) {
texting[i] << i << "# - " << dat.topScore[i];
str[i] = texting[i].str();
displayFont.showHighscore[i] = TTF_RenderText_Solid(displayFont.menuFont,str.c_str(), displayFont.colorText); // OUTPUTTING ERROR :/
posHighscore[i].x = 50;
posHighscore[i].y = 50 * (i+1);
}
while (true) {
for (int i = 0; i < 10 ; i++) {
SDL_BlitSurface(displayFont.showHighscore[i],NULL,screen,&posHighscore[i]);
} // Show the rendered text
SDL_Flip(screen);
SDL_Delay(5000);
break;
}
}