读书人

cout中的self都是什么意思,该怎么处理

发布时间: 2012-04-08 14:38:30 作者: rapoo

cout中的self都是什么意思
cout.self ios show base

[解决办法]
是cout.setf 吧
[解决办法]
msdn,man手册等查下不就知道了


Sets the specified flags.


void setf(
fmtflags _Mask
);
fmtflags setf(
fmtflags _Mask,
fmtflags _Unset
);



Parameters
_Mask
The flags to turn on.

_Unset
The flags to turn off.

Return Value
The previous format flags

Remarks
The first member function effectively calls flags(_Mask | _Flags) (set selected bits) and then returns the previous format flags. The second member function effectively calls flags(_Mask & fmtfl, flags & ~_Mask) (replace selected bits under a mask) and then returns the previous format flags.

Example
Copy Code
// ios_base_setf.cpp
// compile with: /EHsc
#include <iostream>

int main( )
{
using namespace std;
int i = 10;
cout << i << endl;

cout.unsetf( ios_base::dec );
cout.setf( ios_base::hex );
cout << i << endl;

cout.setf( ios_base::dec );
cout << i << endl;
cout.setf( ios_base::hex, ios_base::dec );
cout << i << endl;
}


Output

10
a
10
a

读书人网 >C++

热点推荐