What is good practice for generating verbose output?
问题 what is good practice for generating verbose output? currently, i have a function bool verbose; int setVerbose(bool v) { errormsg = ""; verbose = v; if (verbose == v) return 0; else return -1; } and whenever i want to generate output, i do something like if (debug) std::cout << "deleting interp" << std::endl; however, i don't think that's very elegant. so i wonder what would be a good way to implement this verbosity switch? 回答1: The simplest way is to create small class as follows(here is