我正在测试我的轮盘赌类,但由于cin.ignore()不起作用,Visual Studio 不让我看到输出,而且我不知道这里发生了什么,
你能解释为什么我的命令行窗口消失以及为什么这段代码中的cin.ignore()永远不会被调用吗?
太感谢了!
#include "Bet.h"
#include "Table.h"
#include <iostream>
using namespace std;
using namespace Roulette;
int main()
{
cout << "Enter numbers for Split bet:" << endl;
short answer;
vector<short>* Selection = new vector<short>;
for (short i = 0; i < 2; ++i)
{
cin >> answer;
Selection->push_back(answer);
}
cout << "Enter how many chips and chip worth:" << endl;
short chips, worth;
cin >> chips >> worth;
Bet* MyBet = new Bet(TableLayout::European, BetName::Split, chips, worth, Selection);
Bet* Complex = new Bet(TableLayout::European, BetName::VoisinsDeZero, 1, 1);
Complex->PrintProperties();
cin.ignore(); // THIS IS IGNORED!!! WHY??? please...
delete Selection;
Selection = nullptr;
delete Complex;
delete MyBet;
return 0;
}
编辑:
我按 F5 运行程序,然后输入如下数字:
1 进入 2 进入 1 进入 1 进入
在这里 cmd 消失了,无论它不起作用,程序都会跳过 cin.get() (或 cin.ignore() )。