C++ Standard Library: How to write wrappers for cout, cerr, cin and endl?
问题 I do not like using namespace std , but I am also tired of having to type std:: in front of every cout , cin , cerr and endl . So, I thought of giving them shorter new names like this: // STLWrapper.h #include <iostream> #include <string> extern std::ostream& Cout; extern std::ostream& Cerr; extern std::istream& Cin; extern std::string& Endl; // STLWrapper.cpp #include \"STLWrapper.h\" std::ostream& Cout = std::cout; std::ostream& Cerr = std::cerr; std::istream& Cerr = std::cin; std::string