我尝试使用它,但遇到编译错误。不幸的是,我是编译器的新手,不理解该消息。我正在尝试取回默认的 &ostream 标志。有谁知道如何正确重置标志以及报告的错误是什么?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int v = 0xFF;
cout << "0x" << hex << v << resetiosflags(hex) << v << endl;
return 0;
}
汇编:
clang++ -Wall -std=c++11 -pedantic test251.cc && ./a.out
test251.cc:8:33: error: no matching function for call to 'resetiosflags'
cout << "0x" << hex << v << resetiosflags(hex) << v << endl;
^~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/iomanip:66:3: note:
candidate function not viable: no known conversion from
'std::ios_base &(std::ios_base &)' to 'ios_base::fmtflags' (aka
'std::_Ios_Fmtflags') for 1st argument
resetiosflags(ios_base::fmtflags __mask)
^
1 error generated.