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
Printable View
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
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.
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
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