how to clear ostringstream?

2008/09/18
By

下面這程式真有清掉嗎?

ostringstream os;

os.clear();
cerr << os.str()

沒有!得用

os.str("");

才行

Tags:

2 Responses to how to clear ostringstream?

  1. jeffhung on 2008/09/20 at 7:15 下午

    stream 的 clear() 是用來清除 state flags 的。

    See C++98 27.4.4.3.4~5。

  2. clsung on 2008/09/21 at 8:14 上午

    所以說,真是不直覺 :-/

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*


*