Error 1 error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class Ebook &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@AAVEbook@@@Z) referenced in function _main D:\My Documents\Study\C++ Workplace\Courswork_2_Library\Courswork_2_Library\main.obj Courswork_2_Library
This is my operator overloading: std::ostream& operator<<(std::ostream& out, const Ebook& b){
out <<b.gettype() <<"BookID = "<<b.getid()<<", number of downloads left = " <<b.Ebook::getMaxDownload()-b.Ebook::getDownloads()<<" downloaded by users"<<b.Ebook::getLastUser();
return out;
}
And this is where I use it: string mes(bool b)
{
return (b == true ? " (is successful) " : " (fails) ");
}
int main()
{
ofstream output("output.txt",ios::out);
if (output == NULL)
{
cerr << "File cannot be opened" << endl;
exit(0);
}
#if TESTLEVEL > 0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// testing Ebook class
{
int i;
Ebook eb(100,3);
output << eb << endl << endl;
for (i=2; i<9; i++)
{
if (eb.download(i/2) == true)
output << "successful download of book " << eb.getid() << " by user " << i/2 << endl;
else
output << "unsuccessful download of book " << eb.getid() << " by user " << i/2 << endl;
output << eb << endl << endl;
}
}
#endif
Please help me, I have spend so much time on that and all in vain. Thank you.