4条回答 默认 最新
- ปรัชญา แค้วคำมูล 2016-03-07 10:37关注
// using ios_base::fmtflags
#include // std::cout, std::ios_base, std::ios,
// std::hex, std::showbase
int main () {// using fmtflags as class member constants:
std::cout.setf (std::ios_base::hex , std::ios_base::basefield);
std::cout.setf (std::ios_base::showbase);
std::cout << 100 << '\n';// using fmtflags as inherited class member constants:
std::cout.setf (std::ios::hex , std::ios::basefield);
std::cout.setf (std::ios::showbase);
std::cout << 100 << '\n';// using fmtflags as object member constants:
std::cout.setf (std::cout.hex , std::cout.basefield);
std::cout.setf (std::cout.showbase);
std::cout << 100 << '\n';// using fmtflags as a type:
std::ios_base::fmtflags ff;
ff = std::cout.flags();
ff &= ~std::cout.basefield; // unset basefield bits
ff |= std::cout.hex; // set hex
ff |= std::cout.showbase; // set showbase
std::cout.flags(ff);
std::cout << 100 << '\n';// not using fmtflags, but using manipulators:
std::cout << std::hex << std::showbase << 100 << '\n';return 0;
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 (标签-STM32|关键词-智能小车)
- ¥20 关于#stm32#的问题,请各位专家解答!
- ¥15 (标签-python)
- ¥15 第一个已完成,求第二个做法
- ¥20 搭建awx,试了很多版本都有错
- ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
- ¥15 activiti工作流问题,求解答
- ¥15 有人写过RPA后台管理系统么?
- ¥15 Bioage计算生物学年龄
- ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?