Whenever I try to run this program it returns an error saying:
no operator "<<" matches these operands
Also note that the program only runs into this problem in the getChoice()
function.
#include <iostream>
#include "utilities.h"
using namespace std;
int getChoice(string inChoices[]){
int numOfChoices = sizeof(inChoices) / sizeof(inChoices[0]);
string x = inChoices[0];
string y = inChoices[1];
cout << x << endl << y << endl;
return numOfChoices;
}
int main()
{
string choices[2] = { "Happy Day", "Even Better Day" };
cout << utilities::getChoice(choices) << endl;
cout << endl << sizeof(choices) / sizeof(choices[0]) << endl;
}
You need to
#include <string>
And your calculation of
numOfChoices
ingetChoice()
is wrong, since the parameterinChoices
is actually a "pointer to string" instead of "array of strings".You need also to include the
string
header: