开发者

stream << set_of_dices.dies[die].getStringRow(row) << " ";

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.


You have probably forgotten to #include <string>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜