I got both the codes from Books from an Online PDF
First -
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
Second -
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" ;
return 0;
}
I got both the codes from Books from an Online PDF
First -
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
Second -
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" ;
return 0;
}
No difference, using namespace std; simply means everything that is otherwise available via std namespace no loner needs the std:: prefix. In a cpp file its a personal preference. In an h file - don't use using namespace std;, this is because std namespace is huge, and you may be not the only one including that h. For a beginner, or 'academic' code in general it doesn't really matter, but believe me, when you are on the receiving end of someone pulling the entire std namespace in on you in a big project, you aren't gonna like it.