0
Using namespace std vs std::
I been reading some different books and some use using namespace std and others use std:: . Can someone explain the difference? Also to my understanding i think that syntaxes with std:: in front of it would lose that portion of it if i declare using namespace std. For example std::cout is the same as typing cout and declaring namespace in the beginning where the std:: portion is gone. Is my hypothesis about this correct? Thanks.
5 Respostas
+ 4
Yes, declaring namespace std to be used and then using cout or anything that would usually have std:: in front of it would be the same as using it with std:: in front of it.
However, using namespace std is often recognized as a bad practice, as it could cause namespace collisions.
+ 3
Yes, absolutely.
+ 3
No problem.
+ 1
So i should just practice using std:: for good measure?
+ 1
Thank you :)