Under the circumstances, a using
directive seems highly suspect. While there are times/places that it's useful, this doesn't seem (to me) to be one of them.
The name of a typical class should also be a noun, not a verb. A verb signals that what you have is a single action, which is not a good candidate for a normal class. If it's going to be a class at all, it should probably be a functor. I'd also add a parameter (with a default value) so it would be easy to use a stream other than std::cout
when/if necessary:
struct Print {
std::ostream &operator()(std::ostream &os = std::cout) {
return os << "whatever\n";
}
};
Using system("pause");
is also quite non-portable. If you want to wait for the user to press a key before ending the program, it's generally better to build that into your own code:
void pause() {
std::cout << "Press \"enter\" when ready.\n";
getchar();
}
int main() {
Print()();
pause();
return 0;
}
Frankly, even using the functor strikes me as silly in this case though -- you're taking something simple (print out a string) and making it much more complex without getting anything in return. Given how little the program does, the Print
class accomplishes nothing useful or positive at all.