In: Computer Science
/*If you have any query do comment in the comment section else like the solution*/
If you'll declare the using namespace above main, then while using any standard object you do not have to write std::, but if you will declare inside a function then the inbuild objects can be used only inside that function without writing std::
Ex: Using namespace above main, then there is no need to use std:: inside any function to use cout.
#include <iostream>
using namespace std;
void fun() {
cout<<"Inside fun";
}
int main()
{
cout<<"Hello World";
fun();
}
Using name space inside a function, it has been declared inside fun() method so to use cout there is no need to prepend it with std::, but since it is local to function fun(), you have to use std::before cout to make it work properly
#include <iostream>
void fun() {
using namespace std;
cout<<"Inside fun";
}
int main()
{
std::cout<<"Hello World";
fun();
}