#include <iostream> using namespace std; class abc { double n; public: abc() { n = 67.5; cout << "1\n"; } abc(double num) { set(num); cout << "2\n"; } double get() const { cout<<"3\n"; return n; } virtual void set(double num) { if (num < 10) n = 10; else if (num > 100) n = 100; else n = num; cout << "4\n"; } }; class def: public abc { double m; public: def() { m = 6.2; cout << "5\n"; } def(double num1, double num2): abc(num1) { set(num2 - abc::get()); cout << "6\n"; } double get() const { cout << "7\n"; return m + abc::get(); } void set(double num) { if (num < 10 || 100 < num) m = num; else m = 55; cout << "8\n"; } }; void do_it(abc &var, double num) { cout << var.get() << '\n'; var.set(num); cout << var.get() << '\n'; } int main() { abc x(45); def y(2, 340); cout.setf(ios::fixed); cout.precision(3); do_it(x, 200); do_it(y, 253); cout << x.get() << '\n'; cout << y.get() << '\n'; return 0; }
With the code above, I just wanted to know what below the two lines really will be in the code above
cout.setf(ios::fixed); cout.precision(3);
Please do not just give me an answer, some explanation will be so appreciated, because I am doing a step-by-step guide to prepare for my final exam tomorrow.
I searched, and some source says that it should set flags, but in fact I donβt understand what the concept is and how it works.
Ali
source share