【发布时间】:2017-04-25 18:48:15
【问题描述】:
World::World() {
int width = -1;
int height = -1;
cout << "Aby rozpoczac gre wpisz rozmiar planszy" << endl;
cout << "Aby uruchomic domyslne romiary zostaw pole puste" << endl;
cout << "Podaj szerokosc: ";
// I don't see what i'm typing and i need to press enter twice;
cin >> width;
cout << "Podaj wysokosc: ";
// I don't see what i'm typing too and make my program crash
cin >> height;
World(height, width);
}
couts 工作得很好,但 cin 实在是太糟糕了。 在第一次输入时,我看不到我在输入什么,我需要按两次回车; 在 secend cin 时,我也看不到任何东西,当我按任意键时,程序崩溃
【问题讨论】:
-
您向我们展示的代码应该可以工作。您的问题出在其他地方。
-
你认为
World(height, width);是做什么的? -
我的建议是学习使用调试器。不要急于认为你发现了某种类型的编译器或系统错误。
-
您真的需要
std::endl需要的额外内容吗?'\n'结束一行。