我一直在尝试构建我发现的这个旧的“文本冒险”,
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
/////////////////////////////////////////////////////// VARIABLES //////////////////////////////////////////////////////////
string name;
string shipName;
int health;
int crewCount;
int armyTotal, activeArmy;
int casualtiesCount, woundedCount, healedCount;
// 'food' as in a whole meal (beverage, chewables, etc)
int foodCount;
////////////////////////////////////////////////////// INTRODUCTIONS ///////////////////////////////////////////////////////
cout << "What is thy name?\nName: ";
cin >> name;
cout << endl << "What will you name your ship?\nShip Name: ";
cin >> shipName;
cout << "\nSETTING: You are floating through space on giant space cruiser " << endl << "known as the " << shipName << ".\n You are on a random patrol sorti, just looking out for any trouble...";
cout << "Press ENTER to continue...";
cin.get();
cout << "\nFrom here on out, type corresponding number to which choice you want to make.\nPress ENTER to continue...";
cin.get();
//////////////////////////////////////////////////////// BEGINNING ////////////////////////////////////////////////////////
cout << endl << "Admiral " << name << ", we need you on flight deck.";
cout << "1: Go to flight deck.";
cout << "2: Go to kitchen.";
cout << "3: Go to MedBay.";
cout << "4: Do nothing.";
}
我得到一个错误:
cin >> name;
其中“>>”不匹配任何操作数。我清楚地记得这段代码在我相信的某个时候有效。如果我尝试向前跳过,我会收到一个找不到 exe 的错误(并且没有 Build Final 选项)
抱歉不清楚,但我已经有几年没有使用 C++ 了,几乎所有东西都生锈了。有什么智慧可以流露出来吗?