+ 1

What does namespace mean?

6th Sep 2018, 3:24 PM
Gauri Shirkande
Gauri Shirkande - avatar
10 Réponses
+ 1
It allows you to use the same function or class name in different parts of the same program without causing a name collision. In simple terms, think of a namespace as a person's surname. If there are two people named "John" you can use their surnames to tell them apart.
6th Sep 2018, 4:25 PM
Kshitij Shukla
Kshitij Shukla - avatar
+ 2
https://code.sololearn.com/w5GueTR0Sf7x/?ref=app see this, this will better help you understand. upvote if it helps.
6th Sep 2018, 4:31 PM
Kshitij Shukla
Kshitij Shukla - avatar
+ 2
yep, totally. although it's not available in C. https://code.sololearn.com/cPR3Eg7asfcP/?ref=app
6th Sep 2018, 4:38 PM
Kshitij Shukla
Kshitij Shukla - avatar
+ 1
A namespace is used to uniquely identify one or more names from other similar names of different objects, groups or the namespace in general. Namespace makes it possible to distinguish objects with similar names but different origins
6th Sep 2018, 4:21 PM
Kshitij Shukla
Kshitij Shukla - avatar
+ 1
But what is it meant for?
6th Sep 2018, 4:22 PM
Gauri Shirkande
Gauri Shirkande - avatar
+ 1
OK...thank you😄
6th Sep 2018, 4:28 PM
Gauri Shirkande
Gauri Shirkande - avatar
+ 1
Is this applicable for C++ too?
6th Sep 2018, 4:33 PM
Gauri Shirkande
Gauri Shirkande - avatar
+ 1
Do we write 'using namespace std; in C++ for this very purpose?
6th Sep 2018, 4:43 PM
Gauri Shirkande
Gauri Shirkande - avatar
+ 1
Packages and the Java Namespace. A package is a named collection of classes (and possibly subpackages). Packages serve to group related classes and define a namespace for the classes they contain. ... The String class, for example, is part of the java.lang package, so its fully qualified name is java.lang.String. namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries. https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx Namespace is a feature added in C++ and not present in C. A namespace is a declarative region that provides a scope to the identifiers (names of the types, function, variables etc) inside it. Multiple namespace blocks with the same name are allowed. All declarations within those blocks are declared in the named scope. https://www.geeksforgeeks.org/namespace-in-c/ https://www.geeksforgeeks.org/difference-namespace-class/
5th Nov 2018, 2:08 PM
deepak sharma
deepak sharma - avatar
0
yep, you're right
6th Sep 2018, 4:46 PM
Kshitij Shukla
Kshitij Shukla - avatar