Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespaces and C++

Tags:

c++

namespaces

I have observed that in C++ namespaces are very rarely used while in .Net it is very common. Is there any particular reason for this.

Also i would like to know if others have seen namespaces being used commonly in C++.

EDIT: Actually i am referring to custom applications and not standard libraries like STL or any other thing.

like image 403
ckv Avatar asked Aug 02 '10 16:08

ckv


1 Answers

In C++, namespaces were added to the language some time after the initial implementation, so there was much application code that didn't use them. So, also due to their late addition, all of the standard library was put into one namespace. Hence with a simple using namespace std; you could pretty much ignore namespaces if you wanted to.

In C#, on the other hand, namespaces were involved from the very start, and the library was divided out over a large number of them. Further, the Wizards everyone uses to create their initial code, put the classes into a namespace by default. This forced a much greater awareness of namespaces.

like image 169
James Curran Avatar answered Oct 09 '22 19:10

James Curran