Namespace in c++ Program

Namespace is a function which is used to differentiate between two functions or classes that has function with the same name. Namespace start with keyword "namespace" just like class keyword . After this we give namespace a name and define it scope . whenever we want to access a desire functions (same name) we just reference it namespace and then give the function name.

Source Code  


#include<iostream>
using namespace std;
 namespace  st_namespace
 {
  void LEP ()
  {
   cout<<" LEP Provide you world best platform to learn Programming. You Can Visit us at \n \n ";
  }
 }
  namespace  nd_namespace
 {
  void LEP ()
  {
   cout<<" \t \t \t www.ancodingpoint.com \n";
  }
  
 }
 int main ()
 {
  st_namespace::LEP();
  nd_namespace::LEP();
 }

Output of the Program

C++ Prgramming

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.

2 comments:

  1. This site is full of 'great' {tab} {tab} {tab} programming. There, perfect spacing (on my screen anyway).
    Heh. All the good languages have string formatting/padding. I remember some of my first programs looking like that, but nowadays it is inexcusable. Not to mention the weird use of namespaces for no real reason.

    ReplyDelete
  2. The page crashed for me on android with the cpu getting hot. Seems legit.

    ReplyDelete