Jump to content
  • Advertisement
Sign in to follow this  

"unresolved external symbol" w/ operator overloading

This topic is 5387 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!