Why we use Namespace

In Namespace there are some classes, functions and structs.

So what is the use of namespaces?Why we are adding all things in single collection?


I had seen the example of two namespaces and read that how to access there variables in main.

But I want to know the purpose to write the namespace???

Thanks
A crude example, i think this will clear ur doubt.
1
2
3
4
5
6
7
8
9
10
11
12
13
namespace ABCBank{
int interest;
}
namespace CBCBank{
int interest;
}

int main()
{

 ABCBank::interest=10;
 CBCBank::interest=9;
}
Topic archived. No new replies allowed.