I'm reading Larry Ullman's C++ Programming:Visual Quickstart Guide. He says to use the command std::cout.setf(std::ios::fixed)) (with others) to set the number of digits after a decimal. But all of his code uses std::cout::setf(std::ios_base::fixed). What is the difference?

Recommended Answers

All 3 Replies

So no one here knows the difference between ios and ios_base in this application?

std::ios is outdated:

The C++ Standard has replaced ios::fixed with ios_base::fixed and ios::floatfield with ios_base::floatfield . If your compiler does not accept the ios_base forms, try using ios instead; that is, substitute ios::fixed for ios_base::fixed , etc.

Hope this helps

So use ios_base instead of just ios. Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.