J4ke wrote: |
---|
And when I say well on your way, I mean you've just started. I've been programming for around 3 years and I'm still learning something new every day. |
[EDIT] Though, learncpp.com does something that I think is a little annoying and overkill. #include <iostream> class NAME{ using namespace std; //.... }; void funct(...) { using namespace std; //...... } int main() { using namespace std; // ....... return 0; } |
<math>
functions though, I think you should, as you will find them helpful if you use programming as a means to create proofs (I did read an article in which mathmaticians were programming algorithms to prove theorums).
DTSCode wrote: |
---|
that should never be done. ever. there is nothing wrong with limiting the scope you want to bring in namespaces to, but that is very bad in fact down right pointless(except for learning about scope) it is always much better to just specify what you want to bring in |
using namespace std;
is when I am trying to just do something real quick and don't really know what I'm going to use just yet. See, for me it is easier to doing using namespace std;
and then going back and changing that one line to using std::cin; using std::cout; using std::vector; using std::string;
instead of doing std:: in front of everything and then deciding to go back through to add the using and remove the std:: in the code. Don't get me wrong, if I'm doing my own library tests I do std:: and don't even think about doing using
. Mainly do using for when I'm doing silly game tests to test an idea.
using namespace
declarations aren't bad practice, it's when they are placed in global scope that they become bad. I use them at function scope all the time, especially with boost which has a lot of nested namespaces.
BHXSpecter wrote: |
---|
Using it in function scope means you have to continually call it. |
using namespace
is always bad and should never be used isn't completely correct.
naraku9333 wrote: |
---|
My point was that blindly saying using namespace is always bad and should never be used isn't completely correct. |
Michael Dawson wrote: |
---|
A language purist would say you shouldn't employ either version of using and that you should always prefix each and every element from a namespace with its identifier. In my opinion, that's like calling your best friend by his first and last name all the time. It just seems a little too informal. |