开发者

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

开发者 https://www.devze.com 2023-02-03 11:40 出处:网络
Whats the difference between std::cout<<std::setbase(8)<<32; and std::cout<<std::oct<<32; Are they equ开发者_运维百科ivalent?

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

精彩评论

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

关注公众号