views:

45

answers:

1

Hi,

I get the following error when I try to run my application in Visual Studio 2010:

Error 1 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) new folder\setofdices.cpp 55 1 test1

And the function is:

   //Overload of the operator '<<' to enable printing the set of dices directly using "cout << my_set_of_dices;"
ostream &operator << (ostream &stream, const SetOfDices &set_of_dices)
{
    for(int row=0; row<DICE_MAX_ROWS; row++)
    {
        for(int die=0; die<set_of_dices.nDices; die++)
            stream << set_of_dices.dies[die].getStringRow(row) << "   ";
        stream << endl;
    }
    for(int n=0; n<set_of_dices.nDices; n++)
        stream << "  " << (n+1) << ":" << set_of_dices.dies[n].getDieValue() << "     ";

    stream << endl;
    return stream;
}

How could I fix this?

Thanks.

+4  A: 

You have probably forgotten to #include <string>.

James McNellis