cpp using namespace code example
Example 1: using namespace std in c++
#include
using namespace std;
int main()
{
cout << "Hello World";
system("pause");
return 0;
}
Example 2: c++ custom namespace
//using namespaces
using namespace std;
//creating namespaces
namespace custom{
class example{
public:
static int method(){
return 0;
}
};
};
//using custom namespaces
using namespace custom;
Example 3: namespace c++
Namespace std::cout or cout <<
Example 4: access the namespace members using namespace member function
namespace Parent
{
inline namespace new_ns
{
template
struct C
{
T member;
};
}
template<>
class C {};
}