LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2004, 03:52 PM   #1
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
using multiple namespaces over in C++


I have a quick question about. Assume I have the following files:

file.h
Code:
...
using namespace std;
...
file.cpp
Code:
...
#include file.h
...
using namespace std;
....
file2.h
Code:
...
using namespace std;
...
file2.cpp
Code:
...
#include file.h
#include file2.h
...
using namespace std;
....
Is there any problem with something like that or does the compiler ignore it when it sees you trying to use the same namespace more than once? Is it bad programming practice? I did a quick search and couldn't find what I was looking for. Thanks!
 
Old 09-22-2004, 04:15 PM   #2
greg108
Member
 
Registered: Aug 2003
Location: CA USA
Distribution: FC2, FC4, Mandrake 10, Slackware 10, RedHat 9, Suse 9.1, College Linux, Debian Sarge, Gentoo
Posts: 170

Rep: Reputation: 30
You have to put
using namespace std;
in every implementation file ( *.cpp) if you need it

You should not put it in the specification file ( *.h)
and most likely you don't need it there.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++: recursive #including: partial namespaces? R00ts Programming 4 03-09-2005 12:15 AM
Namespaces ChemicalBurn Programming 10 02-16-2005 09:49 AM
Red Hat 7.3 and multiple gateways on multiple interfaces bluefmc Linux - Networking 2 11-19-2004 05:01 PM
Need an advice for: Multiple Disks&Multiple Penguins and a XP :) thesappho Linux - Newbie 1 12-15-2003 03:13 PM
Multiple Apache Sites, on Multiple IP's, on Same Box?? RickyJ Linux - General 1 06-19-2003 10:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration