[Solved] Don’t print variable if it’s zero
I don’t think you can avoid doing the condition and printing if non-zero somewhere. About all you can do is wrap it up so most code doesn’t need to deal with it: class complex { double x; double i; public: // … friend std::ostream &operator<<(std::ostream &os, complex const &c) { // if both parts are … Read more