Given the following Song and Album classes, which copy constructor is an example of a deep copy of the Album class? Note
Posted: Fri Apr 29, 2022 8:03 am
Given the following Song and Album classes, which copy constructor is an example of a deep copy of the Album class? Note the type of the songs variable. class Song{ public: Song(const string& name, const string& lyrics); private: string name; string lyrics; class Album { public: Albundefined It string& name): name(name), numSongs (e){} Album(Album&); void addSong(const string& name, const string& lyrics) { songs(numSongs++] = new Song(name, lyrics); } private: string name; Song songs [256]; int numSongs; Album(Album& al){ for (int i = 0; i < al.numSongs; ++i) { songs [1] = new Song(*(al.songs)); } Album(Album& al){ songs = al.songs; Album(Album& al){
Album(Album& al){ for (int i 0; i < al.numSongs; ++i) { songs[1] = new Song(*(al.songs)); } Album(Album& al){ songs = al.songs; Album(Album& al){ songs - new Song[256]; for (int i = 0; i < al.numSongs; ++i) { songs al.songs; } Album(Album& al){ songs = new Song [256]; for (int i = 0; i < al.numSongs; ++i) { songs = new Song(*(al.songs)); } Album(Album& al) { for (int i 0; i < al.numSongs; ++i) { songs[1] al.songs; }
Album(Album& al){ for (int i 0; i < al.numSongs; ++i) { songs[1] = new Song(*(al.songs)); } Album(Album& al){ songs = al.songs; Album(Album& al){ songs - new Song[256]; for (int i = 0; i < al.numSongs; ++i) { songs al.songs; } Album(Album& al){ songs = new Song [256]; for (int i = 0; i < al.numSongs; ++i) { songs = new Song(*(al.songs)); } Album(Album& al) { for (int i 0; i < al.numSongs; ++i) { songs[1] al.songs; }