why we use namespace std in c++ code example
Example 1: using namespace std in c++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
system("pause");
return 0;
}
Example 2: what is namespace in c++
#include <bits/stdc++.h>
using namespace std;
namespace abc
{
void fun()
{
cout<<"Hello world"<<endl;
}
int x=10;
}
using namespace abc;
int main()
{
cout<<10;
fun();
return 0;
}
Example 3: c++ namespace example
#include <iostream>
using namespace std;
namespace square{
int x;
int y;
}
int main(){
using namespace square;
x = 10;
y = 0;
cout << x << y << endl;
}