P
Patrick Guio
Dear all,
I have some problem with insertion operator together with namespace.
I have a header file foo.h containing declaration of classes, typedefs and
insertion operators for the typedefs in a named namespace
namespace foo
{
class Foo
{
typedef std::vector<unsigned char> Vec;
typedef std::vector<Key> VecVec;
....
};
std:stream & operator<<(std:stream &os, const Foo::Vec &v);
std:stream & operator<<(std:stream &os, const Foo::VecVec &v);
}
Then the definition in the file foo.cc
namespace foo
{
std:stream & operator<<(std:stream &os, const Foo::Vec &v)
{
...
}
std:stream & operator<<(std:stream &os, const Foo::VecVec &v)
{
}
}
Now I would like to use the insertion operators in a programm. If the
program looks like
#include "foo.h"
int main()
{
Foo::Vec vec;
Foo::VecVec vecs;
....
// "using namespace" directive required
// otherwise compiler get confused with
// other available insertions in std::
{
using namespace foo;
std::cout << vec << std::endl;
std::cout << vecs << std::endl;
}
}
I wonder how to avoid using the using namespace directive?
Sincerely,
Patrick
I have some problem with insertion operator together with namespace.
I have a header file foo.h containing declaration of classes, typedefs and
insertion operators for the typedefs in a named namespace
namespace foo
{
class Foo
{
typedef std::vector<unsigned char> Vec;
typedef std::vector<Key> VecVec;
....
};
std:stream & operator<<(std:stream &os, const Foo::Vec &v);
std:stream & operator<<(std:stream &os, const Foo::VecVec &v);
}
Then the definition in the file foo.cc
namespace foo
{
std:stream & operator<<(std:stream &os, const Foo::Vec &v)
{
...
}
std:stream & operator<<(std:stream &os, const Foo::VecVec &v)
{
}
}
Now I would like to use the insertion operators in a programm. If the
program looks like
#include "foo.h"
int main()
{
Foo::Vec vec;
Foo::VecVec vecs;
....
// "using namespace" directive required
// otherwise compiler get confused with
// other available insertions in std::
{
using namespace foo;
std::cout << vec << std::endl;
std::cout << vecs << std::endl;
}
}
I wonder how to avoid using the using namespace directive?
Sincerely,
Patrick