0

リスト項目

void MovieDatabase::  addActor(const string movieTitle, const string actorFirstName, const string actorLastName, const string actorRole ){
    bool found = false;
    Movie* temp;
    for(Movie* m= headMovie; m != NULL;  m = m-> next){
            if(m-> title == movieTitle){
                found = true;
                temp = m;
                break;
            }
    }

    if(found){
            if(headCast == NULL)
                    headCast =  new Cast(actorFirstName, actorLastName, actorRole, movieTitle);
            else{
                    Cast *c =  new Cast(actorFirstName, actorLastName, actorRole, movieTitle);
                    Cast *temp = headCast;
                    for(Cast* cur = headCast; cur -> next != NULL;  cur = cur -> next){
                             if(cur ->next -> lastName <  actorLastName){
                                    temp = temp -> next;
                            }
                            else{
                                    c -> next = cur -> next;
                                    temp  -> next= c;
                                    break;
                            }
                    }
            }
    }
    else
    cout << "The movie with a " << movieTitle << "  does not exist in the database,you can not add the actor. " << endl;
    size++;
}

こんにちは、私はコードを編集しました。ただし、出力として何も表示されません。これは、何も追加しないことを意味します。いずれにせよ、表示用のコードを送信しています。

void MovieDatabase:: showActors(){
    for(Cast * cur= headCast;  cur != NULL; cur = cur -> next){
         cout  << cur  -> lastName << endl;
    }
}
4

1 に答える 1