And this is my Song consturctor. I have destructors for my Song and Album classes which delete song's name and album's name and songs. In my main I create 3 songs and put them in a album:
1 2 3 4 5 6
Song battery("Battery", 8, 312);
Song master("Master of Puppets", 10, 516);
Song thing("The Thing That Should Not Be", 5, 397);
Song songs[] = {battery, master, thing};
Album sAlbum("Master of Puppets", songs, 3, 300000, 1986);
sAlbum.print();
Everything goes ok but on return 0 it calls heap corruption error. I am trying for half a day already to find where the things break, but no success... :(
here you are creating two copies of songs but underlying pointer is only one... try to put breakpoints in destructors of the classes. more code can give more clear view.
Well I debuged it with break points on all deletes. Then I removed the delete from Song's destructor and it worked. I guess I was deleting the same object twice: once in Song's destructor and once in Album's destructor - when deleting songs array