std::ios::oct 与 std::oct 的不同

std::oct

  inline ios_base&
  oct(ios_base& __base)
  {
    __base.setf(ios_base::oct, ios_base::basefield);
    return __base;
  }

std::ios::oct

static const fmtflags oct =         _S_oct;

全都在ios_base.h里面...

std::ios返回一个ios_base&对象,std::ios::oct就只是一个数...

所以设置std::cout输出格式的时候应当用std::oct而不是std::ios::oct

其余hex/dec 大概同理

posted @ 2019-06-08 16:46  浅蓝星  阅读(406)  评论(0)    收藏  举报