copy pasted array tutorial, got errors
Getting 31 errors like:
-Invalid overload of 'find'
-Symbol 'armor' could not be resolved
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int MAX_ITEMS = 10;
string inventory[MAX_ITEMS];
int numItems = 0;
inventory[numItems++] = “sword”;
inventory[numItems++] = “armor”;
inventory[numItems++] = “shield”;
cout << “Your items:\n”;
for (int i = 0; i < numItems; ++i)
cout << inventory[i] << endl;
cout << “\nYou trade your sword for a battle axe.”;
inventory[0] = “battle axe”;
cout << “\nYour items:\n”;
for (int i = 0; i < numItems; ++i)
cout << inventory[i] << endl;
cout << “\nThe item name ‘“ << inventory[0] << “‘ has “;
cout << inventory[0].size() << “ letters in it.\n”;
cout << “\nYou find a healing potion.”;
if (numItems < MAX_ITEMS)
inventory[numItems++] = “healing potion”;
else
cout << “You have too many items and can’t carry another.”;
cout << “\nYour items:\n”;
for (int i = 0; i < numItems; ++i)
cout << inventory[i] << endl;
return 0;
}
|
Thanks for any help
These errors have to do with the fact that the string literals aren't surrounded by the standard quotation marks that the compiler expects.
What you have:
“”
What is expected:
""
Topic archived. No new replies allowed.