I have this little class widget
that uses a std::string
. It uses it in many places, often in conjunction to a std::vector
. So you can see, that the typenames become very long and annoying.
I want to utilize the using
keyword, i.e. using std::string;
The question is, where is the best place to place it?
// widget.h file
#ifndef WIDGET
#define WIDGET
// (1)
namespace example {
// (2)
namespace nested {
// (3)
class widget {
public:
// (4)
...
private:
// (5)
std::string name_;
...
};
}
}
#endif
My questions are:
- If I place it in
(1)
then everybody who includeswidget.h
will have their scope polluted withstring
? - In places
(2)
and(3)
, it's the same story as in 1. only that the namespacesexample
andexample::nested
will be polluted in a second file that includeswidget.h
? - In places
(4)
and(5)
, the declaration is quite isolated, but will it be visible in the implementation (Cpp) file and in inheriting classes?
Thanks in advance!