....
Printable View
....
Hi Aurora,
Since this looks like a school assignment, I won't say exactly seems wrong to me, but I'll give you a hint...at least from a quick observations:
[code]
//this should put it in a vector
bool Catalog::Read(ifstream &file)
{
string that_file;
while(file >> that_file) //should read and store in the vector
{
getline(file, that_file);
Song some_song(some_song.GetTitle(), some_song.GetArtist(), some_song.GetAlbum(), some_song.GetType() ); //take it apart and write the song on to that
Add(some_song); //this should call Add and add the songs
}
return true;
}
[/code
You are using the >> and getline functions in a suspicious way. You might take a look at the documentation for std::istream to see if these two functions really are appropriate for your needs.
Next, instantiating some_song looks like a prime opportunity for a segfault to me. I suspect that line isn't what you really meant.
It looks like it should work.
When you are having really bad results, it's always a good idea to look at it in pieces. So, if you aren't sure Catalog::Add(Song) isn't working, then you should write up a really simple test program to verify that it works. You could write a little program that adds 2 or three hard-coded songs to the catalog and then print the catalog. If that doesn't work, then you have only 2 places that you have to look (Add and print). Then, when that works, you can add something else to the test, etc.