This is exactly the kind of thing that the "C++ Coding Standards" book I referenced earlier warns you not to do. If you put a using statement before an #include statement, you could be causing the very kinds of errors that Daved was talking about. Click on that link and read chapter 59 (then buy the book and read all 101 chapters). Try out some of the examples and you'll never put a using before an #include again.Code:#include <iostream> using std::cout; using std::endl; #include <string> using std::string; using std::getline;
If all other things were equal then I'd agree, but unfortunately the compiler can't find all the bugs in your program. You can find a lot of bugs with your eyes that the compiler has no clue about; but if there's a lot of extra clutter, you might skip right over it, especially if you're giving your code a quick 'once over' because Product Management wants the product out the door last week...If you have two options, one which can lead to bugs and another that removes that possibility, then the latter has an advantage over the former.