Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尝试编译以下函数时出现以下错误:
Error: invalid operands of types int and const char [3] to binary operator
我该如何解决?
string getFormattedDate() { formattedDate = Date.getDay() << "/" << Date.getMonth() << "/" << Date.getYear(); return formattedDate; }
你不能这样做,它不是有效的 C++。也许你想要:
#include <sstream> // ... string getFormattedDate() { std::ostringstream ss; ss << Date.getDay() << "/" << Date.getMonth() << "/" << Date.getYear(); formattedDate = ss.str(); return formattedDate; }