Concept of namespace
-
Does C implement the concept of a namespace?
-
Does C implement the concept of a namespace?
Because it has no meaning in C. I suggest you get hold of a book on the language if you want to learn it. The best one ever written is The C Programming Language (2nd Edition): Amazon.co.uk: Brian W. Kernighan, Dennis Ritchie: 8601410794231: Books[^]
-
Does C implement the concept of a namespace?
Nope,
C
has nothing similar toC++
namespaces[^]. It has its intrinsic namespaces, see, for instance C Namespaces[^]. -
Does C implement the concept of a namespace?
C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.
-
C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.
You mean you can not have the same name in the same scope. It is routine to carry the same name such as i, j, count etc but they get restricted to within a local scope as a local variable in a function or unit. Not like there should be many but global variables obviously can't have the same name.
In vino veritas
-
C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.
It is not a limitation. When C was designed there was not thought to be a need for such a feature. But you could still have variables and functions that were limited to specific source modules. And local variables inside functions were hidden from others automatically.
-
C does not provide support for namespace like C++. Without Namespace, we cannot declare two variables of the same name. We can count Namespaces as a limitation of C programming Langauge.
Just to be clear namespaces should not be considered a limitation or a feature that is used to protect the scope of variables. Rather it should be considered as a way to protect other entities like classes and methods. If you have a problem with namespace collision in scopes with variables then you need to refactor your code so variables are not exposed at all.