开发者

setbase(8) and std::cout<<std::oct

Whats the difference between std::cout<<std::setbase(8)<<32; and std::cout<<std::oct<<32; Are they equ开发者_运维百科ivalent?

And also, what is the purpose of 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜