The #include directives indicate which libraries you are using. The reason namespace was created is because in some libraries, more than one function have the same prototypes. To give distinction for these functions, we put them into namespace.
For example, let's have these two header files.
1 2 3 4 5 6 7 8 9 10 11
|
//one.h
//include guards omitted
namespace one{
void f();
}
//two.h
//include guards omitted
namespace two{
void f();
}
|
If we include both headers, the compiler won't be able to tell which f() to call if we call that in our program. However, doing one::f() or two::f() clearly defines which f() to call.
"using namespace" will help remove typing the namespace in your code over and over again. A sample:
1 2 3 4 5 6
|
#include "one.h"
#include "two.h"
using namespace one;
f(); //will call one::f();
two::f(); //still ok, will call two::f();
|
I see no problem in your code if you are not using the C++ standards. In C++ standard, the iostream.h is already deprecated. If you set your flags properly, the compiler will throw that warning. It will also suggest you use:
instead of
If you want to use c-standard libraries, just add 'c' at the beginning of the library name. Example:
The do-while loop is no different from a while loop. The do-while loop ensures that the block is executed at least once before evaluating the condition of the loop.