Im not new to c++ but am still a beginner, i've got 2 questions and they could just be personal preference but need to ask.. while in school we learned by creating empty projects to do our coding, but am doing some pluralsight training to brush up on my skills and the person doing the lessons uses precompiled headers. Is there any benefit to either or if i were making something proffesional would it be better to use the precompiled or an empty project? here is the second question. I also had learned before to always include namespace std; and like before. the lessons im watching at the moment does not use the include namespace instead just does the std::cout << "something" << std::endl; style.. it would seem easier and less coding if you were to include the namespace ,but curious if there's a benefit of one over the other.
Thanks
For the second question: when you use the std:: prefix (or another namespace), it is easier to see which objects are in which namespace: it makes the code easier to read.
Normally, header files are compiled for each source file they are included in. If you have very large headers that are included in several different cpp files, this can cause compilation to take longer. Precompiled headers potentially speed this up by compiling the header only once, then using that compiled data in every source file which includes that header.
Personally, I have had some problems with flakiness of pch files (where they don't always get refreshed/recompiled when they should be)... and those issues outweigh the benefits. So I avoid using them unless they provide a significant reduction in compile time.
Neither approach is more "professional". Some professional projects use pch's, others don't. it depends on the project/team/etc.
2)
Namespaces are meant to avoid name conflicts. The idea is that everything in the standard library is put in the std namespace so that the names of its functions/classes/etc don't get in the way of the names of stuff in your code. By putting usingnamespace std; you are dumping the std namespace into the global namespace, effectively defeating the entire point of using a namespace in the first place.
By precompiled headers I assume you mean libraries such as <string> ?
These are sometimes necessary for you to use the functionalities described in those headers, such as with <string> if you want to use C++ std::string objects.
If you mean creating your own header files in multifile programs, that's mostly done to keep the code structured and easily retreivable.
As for your question on usingnamespace std; have a look at these threads: