0
when to use <iostream.h> and when to use <iostream> would anyone please tell about this!!
I have a confusion about using this header files and I don't know exactly what is namespace std;
6 Answers
+ 1
<iostream.h> and <iostream> both are same you can use any ,it is just a different way to write it.
+ 1
A namespace is a form of scope in C++ that holds its own definitions for variables, functions, etc. For example, bothĀ coutĀ andĀ cin, along with some useful tokens likeĀ endl, are defined inside ofĀ stdĀ for use. As a result, there are two primary ways to access them.
+ 1
The easier way, especially for students learning the language, is the statement in question:
using namespace std;
This tells the compiler that this file should use the namespaceĀ std, so you can simply type lines like this:
cout << "Hello world." << endl;
+ 1
If you do not tell the compiler to use the namespaceĀ std, you need to specify the namespace for every outide object, variable, and function you call. This means you need to use the namespace name and the scope resolutoin operatorĀ ::Ā before the names of anything you need fromĀ std. This would turn the above line into this:
std::cout << "Hello world." << std::endl;
Its all upto you how you want to do it.
+ 1
for the detailed info on <iostream.h> and <iostream> visit http://members.gamedev.net/sicrane/articles/iostream.html
0
thanks a lot Mr.imnoob it was very helpful for me!