Coders Packet

Namespaces Scope(ANSI C++ feature)

By Bharat Pandey

Hello coders, Today we will Learn Namespace. A Namespace is a keyword in ANSI C++ to define a scope that could hold global identifiers.

Have you ever use using namespace std in a C++ programme? 

if yes and not understand what it is this article is for you. so ANSI C++ added a new keyword namespace that could hold global identifiers. 

The best example of namespace scope is the standard template library. 

we can also define our own namespace in the C++ programme.

Syntax : namespace namespace_name { //Declarations of variable, functions, classes, etc }

Example:

namespace function
{
     int val;
     int display()
     {
        cout<< val<<endl;       
     }
}

We can use using directive to access namespaces.

using namespace namespace_name;       //using directive

using namespace_name::member_name  //using declarations.

 

 

 

Download project

Reviews Report

Submitted by Bharat Pandey (Techbharat)

Download packets of source code on Coders Packet