What is namespace? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is namespace?

18th Jan 2017, 6:07 AM
Anmol Srivastava
Anmol Srivastava - avatar
2 Answers
+ 3
Sometimes, you will have different libraries using functions or elements with similar names, and this results in a clash when you try to call them in your program. Namespace is like a class of all these elements with a unique name for each of them so that the compiler wouldn't get confused with the names. An example would be : Consider a class of students. There is a chance that more than one student has the same name. To prevent this, we use roll numbers or ID numbers which are unique to each person. This is exactly what namespace does. It assigns unique name to each of its elements, though they are similarly titled.
20th Jan 2017, 7:12 AM
Snehith Haridas
Snehith Haridas - avatar
+ 2
It's logical separation of the difference types (classes or types) of same name
20th Jan 2017, 8:49 AM
Ramesh Papaganti
Ramesh Papaganti - avatar