0

次の関数をコンパイルしようとすると、次のエラーが発生します。

Error: invalid operands of types int and const char [3] to binary operator

これを修正するにはどうすればよいですか?

string getFormattedDate()
{
    formattedDate = Date.getDay() << "/" << Date.getMonth() << "/" << Date.getYear();
    return formattedDate;
}
4

1 に答える 1

8

それはできません。有効な C++ ではありません。多分あなたがしたい:

#include <sstream>

// ...

string getFormattedDate()
{
    std::ostringstream ss;
    ss << Date.getDay() << "/" << Date.getMonth() << "/" << Date.getYear();
    formattedDate = ss.str();
    return formattedDate;
}
于 2013-09-03T07:06:56.420 に答える