How to Run a C++ Program Without Namespace?
Last Updated :
02 Nov, 2022
Improve
Prerequisite: Namespace in C++
If we want to run a program without using a namespace, we have to the std keyword along with the space resolution operator (::) in every printing line and variable declaration,
For example,
std::cout<<"geeksforgeeks";
Example:
// C++ Program without the use of using namespace std;
#include <iostream>
#include <string>
int main()
{
std::cout << "geeksforgeeks";
return 0;
}
Output
geeksforgeeks
Example:
// C++ Program without the use of using namespace std
#include <bits/stdc++.h>
int main()
{
int a = 5;
int b = 10;
int c = a + b;
std::cout << c << std::endl;
return 0;
}
Output
15