vendredi 24 novembre 2017

Invalid new-expression of abstract class type 'Playlist'

After reading on other similar problems on stack overflow I still cannot figure out whats wrong with my code. I am implementing the pure virtual function. So I have an observer class and my Playlist class inherits my observer class.

this is the definition of my pure virtual functions in my observer class:

 virtual void update(Subject * subject)= 0;

 virtual void printOn(ostream & out) const = 0;

I implement them in my Playlist class in this manner:

virtual void Playlist::update(Subject * subject){

//UPDATE THE PLAYLIST TO INCLUDE THE PLAYLIST FOLLOWED FROM observer

//SHOULD BE CALLED EACH TIME CHANGES HAPPEN TO FOLLOWED PLAYLIST

Playlist subjectPlaylist = subject.findPlaylist(getName());

int sizeOfTracks = getTracks().size();

  for (int i = 0; i < sizeOfTracks; i++){
    removeTrack(getTracks().begin());
     }

for (vector<Track*>::iterator itr = tracks.begin() ; itr != tracks.end(); ++itr){
    addTrack(*itr);
   }
}


virtual void Playlist::printOn(ostream & out) const{

     out << this <<endl;
  }

I still get this same error and I have tried changing several different things, like removing virtual keyword in the derived class, and so on but I still get this same error.

Aucun commentaire:

Enregistrer un commentaire