Hi, I'm currently writing a program for my C++ class, and there's one error message that keeps popping up everytime I compile that I can't understand.
It says:
1 2 3
137: error: could not convert 'numCreatures' from 'Creatures*' to 'std:: {aka std::basic_string<char>'
error: no match for'operator[]' (operand types are 'Creatures' and 'int')
It's only popping up for these once section of code, and I can't figure out why. Here's the two sections respectively:
int deleteCreatures(Creatures numCreatures[], int curNumCreatures)
{
bool found;
string temp;
"The following is a list of all the creatures you take care of: \n";
for(int i = 0; i < curNumCreatures; i++)
{
cout << numCreatures[i].name << endl;
}
cout << endl << "What creature do you wish to remove?\n";
cout << "CREATURE NAME: ";
getline(cin, temp);
found = moveArrayElements(numCreatures, curNumCreatures, temp);
if(found == true)
{
cout << "You have removed " << temp;
curNumCreatures--;
}
else
{
cout << "Invalid. Please enter a saved creature name.\n";
getline(cin, temp);
}
return curNumCreatures;
}
In your print function you're passing a single instance of your class as a parameter but inside the function your trying to treat this single instance as an array.
In future if you only post a couple of snippets you need to correlate your error messages with the snippets posted. For example which line in the snippets provided is line 137 in your actual code?