starałem poniższy fragment, ale to nie daje pożądany wynik:Różnica stringstream i ostringstream
#include<iostream>
#include<sstream>
using namespace std;
void MyPrint(ostream& stream)
{
cout<<stream.rdbuf()<< endl;
}
int main()
{
stringstream ss;
ss<<"hello there";
MyPrint(ss); //Prints fine
ostringstream oss;
oss<<"hello there";
MyPrint(oss); //Does not print anything
getchar();
}
jestem świadomy, że jedynym możliwym różnice między stringstream
i ostringstream
jest to, że później siły kierunku i jest nieco szybszy niż stringstream
.
jestem brakuje na coś?
PS: Podobne pytanie zostało wysłane wcześniej, ale nie otrzymałem żadnych odpowiedzi.