Reputation: 69
What is the difference between ios::base:precision & setprecision Given in the following links? http://www.cplusplus.com/reference/ios/ios_base/precision/
http://www.cplusplus.com/reference/iomanip/setprecision/
Upvotes: 4
Views: 2755
Reputation: 19262
The difference it to do with the usage. The first (setter) is a member function, so gets called like this:
std::cout.precision(10);
The second isn't a member function so is called different.
std::cout << std::setprecision(10);
The 2nd link explicitly says
"Behaves as if member precision were called with n as argument on the stream on which it is inserted/extracted as a manipulator "
Upvotes: 4
Reputation: 36352
Citing your second link:
Behaves as if member
precision
were called with n as argument on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams).
Thus, there's no difference.
Upvotes: 0