提示ISO C++11 does not allow conversion from string literal to ‘char *‘怎么办

这个错误是因为ISO C++11标准不允许将字符串字面值直接转换为`char*`类型的指针。

C++中解决这个问题的一个方法是将字符串字面值声明为`const char*`类型的指针。

你可以将示例代码中绘制字符的部分修改如下:

const char* text = "Hello";
for (int i = 0; i < strlen(text); i++) {
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, text[i]);
}

这样修改后,你就不会再遇到这个编译错误了。

还可以使用`const_cast`来将字符串字面值的类型转换为`char*`类型的指针。这样做的前提是你确保不会修改这个字符串字面值。

char *renderText1 = const_cast("3333");
    char *renderText2 = const_cast("Esc - Quit");
    renderBitmapString(30,15,font,renderText1);
    renderBitmapString(30,35,font,s);
    renderBitmapString(30,55,font,renderText2);

你可能感兴趣的:(C++开发大全,c++,servlet,开发语言)