Ian Reinhart Geiser on Sat, 15 Feb 2003 00:10:34 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] C++ and namespaces


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 15 February 2003 07:28 am, Jeff Abrahamson wrote:
> I'm using g++ 3.x now, and I'm curious what advice might be given on
> incanting
>
>     using namespace std;
>
> in .h files, in .cc/.cpp files, or being (absurdly) verbose and saying
> std:: all over. Is there a good reason not to just put this in most .h
> files, for example, and be done with it?

Note this is from my years of C++ and seeing using namespace and bad namespace 
usage destroy many many things:

	first avoid using namespace at all costs,  there is a reason namespaces 
exist.  To eliminate collisions of names!

	given this tidbit of knowledge go forth and get use to doing std::cout and  
std::endl along with your own namespaces.  NEVER EVER do using namespace in a 
header file...  anything that includes that file can get polluted and if its 
a public header you can break code down the line.  lastly if you get stuck 
and are really having to deal with some broken toolkit do the using namespace 
in the implementation.  and keep it away from your code and after the 
includes.  if you can isolate it in its own wrapper class that keeps the 
broken toolkit from possibly breaking other stuff you are doing.

	now this is my practice, and many others may not agree.  also keep in mind, 
that i namespace everything i do (personal code) in my own namespace out of 
practice.    in C++ you will find namespaces make code cleaner, and safer.  

	just my 2c
	-ian reinhart geiser
- -- 
- --:Ian Reinhart Geiser <geiseri@yahoo.com>
- --:Public Key: http://geiseri.myip.org:8080/publickey.txt
- --:Jabber: geiseri@geiseri.myip.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+TcfVPy62TRm8dvgRAskoAJ9Fcj4d7vSAVkPrrzIcP0GPp8bxAwCgw+E7
DXvBln5Qz/y0gbaE0eRIVw8=
=6M3z
-----END PGP SIGNATURE-----


_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug