int i = 4;
string text = "Player ";
cout << (text + i);我想让它打印Player 4。
上面的内容显然是错误的,但它显示了我在这里要做的事情。有没有简单的方法可以做到这一点,或者我必须开始添加新的includes?
发布于 2009-06-02 18:47:04
另一种可能性是Boost.Format
#include <boost/format.hpp>
#include <iostream>
#include <string>
int main() {
int i = 4;
std::string text = "Player";
std::cout << boost::format("%1% %2%\n") % text % i;
}https://stackoverflow.com/questions/64782
复制相似问题