|
From: Siva C. <siv...@ya...> - 2004-09-01 04:47:46
|
hello all,
I have a question on using namespaces. Say I want to
build a class ClassA and put it in a namespace abc.
Then I would declare the class in a header file,
header1.h, like:
#ifndef __HEADER1_H__
#define __HEADER1_H__
namespace abc
{ // Start of namespace brace.
class ClassA
{
...
};
} // End of namespace brace.
#endif // __HEADER1_H__
Now I would like to include this header file in
another header file, header2.h. Here again I want to
declare a class ClassB under the same namespace abc.
This ClassB is inherited from ClassA. So to avoid
writing abc::ClassA everywhere I just say:
using namespace abc;
at the begining of the file. My file would be like:
#ifndef __HEADER2_H__
#define __HEADER2_H__
#include "header1.h"
using namespace abc;
namespace abc
{ // Start of namespace brace.
class ClassB : public ClassA
{
...
};
} // End of namespace brace.
#endif // __HEADER2_H__
My question is here: By explicitly putting a statement
like
using namespace abc;
I am including such a statement in all my code which
use this header file header2.h. Is there a way to
avoid such a thing from happening without losing the
functionality I want it to be there for? Or is it that
I am not using it in the right manner?
Thanks a lot for having enough patience to read this
long,
Siva Chandra.
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
|