using namespace std;
This is actually not an ideal practice that I would apply in a professional code base. The reason is that it practically “expands” the std (packages in Java, if you want), where you are probably doing “Hello world” programming, etc., Not as serious as RT Embedded, Mission Critical or Safety Critical. For example, I work at Interservice / Industry Training and Simulation, where security / mission is often important; people would love to have a quiet word with me if I used several namespaces so openly. It doesn't concern the size of your program; it is more about good practice. Yes, if you have so many possibilities to use from the std , then you can probably just use it. The trade-off, as well as what I sometimes do, is:
using std::endl; using std::string; using std::cout; using std::cin;
This "reveals" the ones you will need for this area, and still allows you to use:
string myStr; cout << "Some cout" << endl;
Like what you mentioned in your question. Why not give it a try?
The “good bit” is that if you follow the mentioned approach, it will also “update” your level of knowledge in C ++ namespaces and possible STLs.
I know that some people will say: “Well, it's hard work,” but for me it is a good compromise, to some extent. :)
DO NOT FORGET TO ADD NECESSARY FILE FILES, PLEASE :-)
source share