@
dhayden
Hi, how are you - thanks for pointing out this:
All it does is make the symbols in namespace std that you've declared (via #includes) accessible without the std:: prefix. |
++ThingsLearnt;
I guess that I make comments against using an entire namespace routinely, especially when the OP was arguably doing it in the normally accepted way - I don't like to see someone promoting the "wrong way".
Without trying to be argumentative, it's quite easy to write even a small amount of code that would include a fair bit of stuff from
std
, as in:
1 2 3 4 5 6
|
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <memory>
|
As you mention naming conflict is easily done, even with just
<iostream>
, there is
std::left
and
std::right
, which are used for alignment purposes via
std::cout
, a beginner could easily try to use those as variable names.
It still seems strange that so many authors & lecturers (including Stroustrup) have
using namespace std;
. Even in a Hello World program - the meaning of namespace seems to be glossed over, if not being promoted as being easier.
Anyway, I guess there are bigger things in the world to worry about :+)
@
Ch1156
With your loop, and setting
loopEnd
after each
else if
, the loop only runs once. I would rather there be some sort of Quit option the sets
loopEnd
. That way the user can repeatedly make selections.
Also, you missed the error on line 23.
As others have pointed out the else part should be used to catch errors, and analogous to the
default:
case in a
switch
It's better to use continue; and break; sparingly. |
Not sure what you mean by this.
The OP had them because of the use of the infinite loops - maybe the overuse of them points towards better design (like the use of the boolean in the loop), but otherwise I don't see why one shouldn't use them where ever needed.
Hope all is well with everyone - have a great day :+)