0

私が見つけたこの古い「テキストアドベンチャー」をテストビルドしようとしましたが、

#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++ を使用していません。流すべき知恵はありますか?

4

1 に答える 1

2

する必要があり#include <string>ます。ここで、実際の演算子が定義されます。過去には、<iostream>許可されているが必須 (または保証) されていない可能性があります。

于 2013-09-26T00:26:38.073 に答える