I’ve been stumped on my code all day today. I have a number of classes to deal with a collection of tracks and albums.
My code compiles and it reads in the file successfully, but as soon as i try to use the istream& operator in my Album Collection class it errors at run time.
This is the error:
error LNK2001: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class AlbumCollection &)" (??5@YAAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV01@AAVAlbumCollection@@@Z)1>C:\Users\Shardy\Desktop\AlbumDatabase\Debug\AlbumDatabase.exe : fatal error LNK1120: 1 unresolved externals
I would really appreciate some help. Its become frustrating. None of my books nor google is shedding any light. Thanks for your time.
Some issues:
was loaded successfully. Why bother opening the file in the first
place if it is already loaded? Hmm, how can that be?
if (file)instead ofif (file.is_open())}in theifstatement.argcorargvso you can declaremainas
main(void).method definitions.
something not numeric or whitespace, such as “:”.
correctly, especially overflows. Try adding “00:59:35” with
“00:02:30”.
operator==will return the result of the lastexpression, because you are using the comma, ‘,’ operator. You
probably want to use the
&&or logical AND operator.constructor or destruction you should declare all 3 and an
assignment operator.
operator+oroperator-you should also implement operators+=and-=aswell. See Boost math library.
you should implement operators
<, <=, ==, !=, >,and>=. Hint:convert the time into seconds, which should make your life easier
when comparing. See boost::less_than_comparable.
track.cpp: You’re input method reads the track name first, then
the duration. The data file shows duration first then track name.
You also have no code to deal with the field separator between
duration and column.
Yep, a debugger would be helpful as well as pencil and paper to go through this code.