关于stringstream的有关问题
关于stringstream的问题有一个这样的函数void nextLine(stringstream *ss){ss \n}编译的时候出现下
关于stringstream的问题
有一个这样的函数
void nextLine(stringstream *ss)
{
ss << "\n";
}
编译的时候出现下面的错误。
error C2296: '<<' : illegal, left operand has type 'std::stringstream *'
error C2297: '<<' : illegal, right operand has type 'const char [2]'
请问,我怎么样可以实现这个函数。
我不想用引用,也不想用值传递,也不想用宏,只希望形参是指针。
我应该怎么写?
谢谢各位高人了 C++ stringstream 解引用
[解决办法]改成这样
void nextLine(stringstream *ss)
{
ss[0] << "\n";
}
另外你为什么不想用引用呢?
[解决办法](*ss) <<
[解决办法]直接用 (*ss)<< std::endl;不但能用,还能屏蔽windows和linux下回车的区别
[解决办法]解引(*ss) << '\n';