setbase(8) 和 std::cout<
std::cout< 和 std::cout< 它们等价吗?
另外,std::cout.oct
的目的是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web
技术交流群。
std::cout<
std::cout<
另外,std::cout.oct
的目的是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
std::oct 将 str 流的基字段格式标志设置为 oct。
std::setbase 将基字段格式标志设置为可能的值之一:十六进制、十进制或八进制,具体取决于基本参数的值。
我认为最大的区别是 setbase 接受一个参数,所以你可以向它传递一个包含你想要的数字基数的变量。而不是使用一堆 if 语句来检查变量并使用 dec、oct 或 hex。
但我不确定 std::cout.oct 。
std::oct Sets the basefield format flag for the str stream to oct.
std::setbase Sets the basefield format flag to one of its possible values: hex, dec or oct depending on the value of the base parameter.
I think the big difference is that setbase takes an argument so you could pass it a variable containing the numerical base you want. Instead of having a bunch of if statements to check the variable and use dec, oct or hex.
I'm not sure about std::cout.oct though.