using the namespace std for example. What is the best practice?
being the less keystrokes, but most dangerous to overwrite
This one is probably my favorite (maybe because i am not fluent in c/c++) but i like how it explicitly states what is being used while at the same time not having to type std:: on anything stated below (which seems to be a lot)
1 2 3 4 5
then also along with this one, i can put my includes with what namespace being used under it, so i know what namespace comes from what library.
This is what everyone says you "should" do, but it clutters up the code so much. Everywhere you have vectors and strings comes along with std::. It seems like it clutters up the code a lot. std::cout << somevar << std::endl;
I was just wondering what you guys thought of each. When do you use each? And of course being that the second one is my favorite, is there an problem with using the second method?
I don't want to tell anyone what to do but personally I prefer the third option to put std:: everywhere. Now I'm so used to it that it makes the code easier to read because I can directly see if it's something from the standard library or not.
To me everything seems to be from std. Coming from Python, what is more confusing is something like <iomanip> where setprecision is using std::, my first thought would be that it would have some link to what library it is from, and not jsut a general std with numerous libraries.
something in python would be like:
where urllib is part of the stdlib, but when using it urllib is prefixed everytime, so i know what library it came from.
cout << std::setprecision(5);
how are you suppose to know that seprecision comes from the library iomanip? Aside from remembering, and googling.
no not really. I just recently included iomanip to use std::fixed thinking that that was its library, but then reading someone elses code realized they used fixed without inlcuding that lib. So i was thinking something that more clearly states that confusion.
but i mean fixed manipulates iostream, so i would assume that it would be defined in iomanip, but guess not