i just got a new how to book and they use <iostream> and thennow this is called namespaces right? how's it better/worse than iostream.h and so on. thanksCode:using std:://....
i just got a new how to book and they use <iostream> and thennow this is called namespaces right? how's it better/worse than iostream.h and so on. thanksCode:using std:://....
The official way of doing things is not to include a .h at the end of any standard headers.
Like SilentStrike said,
using namespace std;
is coded as the default namespace
so you don't need to code stuff like std::cout
everytime you need the std namespace.
ok. . . so what's the correct way to fix this
Code:#include <iostream> #include namespace main() { cout<<"hello";//notes return(0); }
#include <iostream>
using namespace std;
int main()
{
cout << "hello";
return 0;
}
There isnt just one correct way. You can use the using directive to include all information from the header into the namespace (this is called global napespace pollution which is what happens when you include iostream.h) or you can just use the scope qualifier ( :: ) and qualifiy each function, class, or so on that you need like:
Code:#include<iostream> using std::cout; using std::endl; int main() { cout << "Hello" << endl; return(0); }
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein