|
-
October 11th, 1999, 05:19 AM
#1
Namespace pollution?
I am just wondering if I use
using namespace std;
in my header .h file, does it stop at the end of header file or it pollutes every .cpp file that includes this header.
Tomaz
-
October 12th, 1999, 07:43 AM
#2
Re: Namespace pollution?
Hi,
if you put using namespace std;in the header .h file - it pollutes every .cpp file that includes this header, as so the declarations of namespace is visible in the scope of a translation unit and #include adds *.h and *.cpp in the single translation unit.
Hope this helps,
Oleg.
-
October 12th, 1999, 09:23 AM
#3
Re: Namespace pollution?
I guess that means that it is bad karma to include using statement in header files since there is no way to terminate the effect of it(?)
And if I declareMyClass::say_it(std::string sWord);
in header file and implement it likeusing namespace std;
MyClass::say_it(string sWord)
in my implementation file class wizard won't match the declaration and implementation of functions.
Sniff, sniff...What do to?
Sincerely,
Tomaz
-
October 12th, 1999, 11:03 AM
#4
Re: Namespace pollution?
I guess the only viable solution is to also implement it with the std:: for ClassWizard's sake, like this:
using namespace std;
MyClass::say_it(std::string sWord)
{
// But in here you can omit the std::
string sAnotherWord = sWord;
}
Cheers!
Alvaro
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|