check your other files, the code is correct and it works for me
look for redefinitions
Last edited on
.H
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
namespace ged
{
namespace Data
{
class GString
{
friend std::ostream& operator<<(std::ostream& s, const GString& other)
{
std::cout << other.mainString;
return s;
}
};
}
}
|
In the cpp I don't even mention that operator overloading function.
The error says:
"class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl ged::Data::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ged::Data::GString const &)" (??6Data@ged@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV23@ABVGString@01@@Z) already defined in main.obj
Last edited on
Also, one can use a namespace alias, if referring to a class from elsewhere, like in main() or some other function say:
namespace gd = ged::Data; // use whatever abbreviation that suits you
Then,
gd::Gstring MyString;
That way it's easier to deal with nested namespaces and you can avoid bringing in the whole namespace.
I find myself doing this all the time when using boost:
namespace bg = boost::geometry;