Sign in to follow this  
Doggan

"unresolved external symbol" w/ operator overloading

Recommended Posts

Doggan    528
I have never ever seen this error before and I am very perplexed. I have two classes, A and B. A contains an array of B's. In B, the << operator is overloaded as a friend function. The definition is as follows (it is correct but i'll post it anyways).
std::ostream& operator <<( std::ostream &rOut, const cfg::B &rProd )
{
	rOut << rProd.GetLHS();
	rOut << "->";
	rOut << rProd.GetRHS();

	return rOut;
}
In a member function (ShowDerivation()) in A, I call << as follows:
std::cout << m_ArrayOfB[ Number ];
I compile, and I get this Linking error: ProjectName error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl cfg::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class cfg::B const &)" (??6cfg@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVCProduction@0@@Z) referenced in function "private: void __thiscall cfg::A::ShowDerivation(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::stack<struct cfg::Token,class std::deque<struct cfg::Token,class std::allocator<struct cfg::Token> > >,int)" (?ShowDerivation@A@cfg@@AAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$stack@UToken@cfg@@V?$deque@UToken@cfg@@V?$allocator@UToken@cfg@@@std@@@std@@@4@H@Z) Everything compiles fine, it's just this one link error. Any ideas? Thanks :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this