|
From: Jason H. <jas...@bt...> - 2002-03-22 02:38:52
|
The use of .h headers is depreciated, meaning that in future C++ =
implementations it may not exist. It is only available for backward =
compatibilty at the moment.
Saying using namespace std; in the global scope is actualy bad =
programming practice. What you might do in a proper program is put =
something like using std::cout; in global scope and occasionally using =
namespace std; in a method, class or block of code that it would be of =
benefit for. You should avoid elevating as much as possible to the =
global scope. Elevating cout would be reasonable as it is used such a =
great deal.
One of the reasons for namespaces is, as mentioned, when multiple =
libraries are added to one project. The different libraries can each =
have thier own namespace so that if both librarys have an "add()" =
function they can be accessed seperatly and won't collide. If you had =
std in the global scope (as it used to be) then everything in that =
namespace that collides with the common names in any other global space =
library will cause the compiler to have a fit. In big projects it makes =
it easier to ensure that method names don't collide.
Jason.
----- Original Message -----=20
From: Daniel Glenfield=20
To: dev...@li...=20
Sent: Thursday, March 21, 2002 6:13 PM
Subject: [Dev-C++] Namespaces
Could someone explain this to me a little bit clearer? Is it just =
saying you need to write the namespace declaration to write headers =
without the .h extention? If so what's the point in that?
Thanks,
Daniel
C++ also supports namespaces. Namespaces simplify the writing of =
programs that combine libraries from various members. The namespace =
feature is not available in C. The statement that must be included in =
the program when using namespaces is using namespace std;.
e.g.
// This is a program to demonstrate the use of namespace.
#include <iostream>
using namespace std;
void main()
{
cout << "Using Namespace";
}
In C++, if you use iostream instead of iostream.h, the namespace =
directive is used to make the definitions in iostream available to your =
program.
-------------------------------------------------------------------------=
-----
MSN Photos is the easiest way to share and print your photos: Click =
Here
_______________________________________________ Dev-cpp-users mailing =
list Dev...@li... =
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|