これが私のコードです:
class LibItem
{
public:
virtual void PrintDetails() = 0;
virtual void setDetails() = 0;
void setTitle(string TitleName)
{
Title = TitleName;
}
string getTitle()
{
return Title;
}
void setReleaseDate(string date)
{
ReleaseDate = date;
}
string getReleaseDate()
{
return ReleaseDate;
}
void setAuthor(string AuthorName)
{
Author = AuthorName;
}
string getAuthor()
{
return Author;
}
void setCopyright(string CopyrightDetails)
{
Copyright = CopyrightDetails;
}
string getCopyright()
{
return Copyright;
}
void setGenre(string GenreDetails)
{
Genre = GenreDetails;
}
string getGenre()
{
return Genre;
}
void setStatus(string StatusDetails)
{
Status = StatusDetails;
}
string getStatus()
{
return Status;
}
private:
string Title;
string ReleaseDate;
string Author;
string Copyright;
string Genre;
string Status;
};
class Book : public LibItem
{
public:
Book(string TitleName)
{
setTitle(TitleName);
}
void setISBN(int ISBNDetails)
{
ISBN = ISBNDetails;
}
int getISBN()
{
return ISBN;
}
void setDetails(string setBookTitle, string setBookAuthor, string setBookReleaseDate, string setBookCopyright, string setBookGenre, string setBookStatus, int setBookISBN)
{
setTitle(setBookTitle);
setAuthor(setBookAuthor);
setReleaseDate(setBookReleaseDate);
setCopyright(setBookCopyright);
setGenre(setBookGenre);
setStatus(setBookStatus);
setISBN(setBookISBN);
}
void PrintDetails()
{
cout << "Title: " << getTitle() << endl;
cout << "Author: " << getAuthor() << endl;
cout << "Release Date: " << getReleaseDate() << endl;
cout << "Copyrite: " << getCopyright() << endl;
cout << "Genre: " << getGenre() << endl;
cout << "Status: " << getStatus() << endl;
cout << "ISBN: " << getISBN() << endl;
}
private:
Book();
int ISBN;
};
class DVD : public LibItem
{
public:
DVD(string TitleName)
{
setTitle(TitleName);
}
void setRunningTime(int RunningTimeDetails)
{
RunningTime = RunningTimeDetails;
}
int getRunningTime()
{
return RunningTime;
}
void setDirector(string DirectorDetails)
{
Director = DirectorDetails;
}
string getDirector()
{
return Director;
}
void setStudio(string StudioDetails)
{
Studio = StudioDetails;
}
string getStudio()
{
return Studio;
}
void setProducer(string ProducerDetails)
{
Producer = ProducerDetails;
}
string getProducer()
{
return Producer;
}
void setDetails(string setDVDTitle, string setDVDAuthor, string setDVDReleaseDate, string setDVDCopyright, string setDVDGenre, string setDVDStatus, int setDVDRunningTime, string setDVDDirector, string setDVDStudio, string setDVDProducer)
{
setTitle(setDVDTitle);
setAuthor(setDVDAuthor);
setReleaseDate(setDVDReleaseDate);
setCopyright(setDVDCopyright);
setGenre(setDVDGenre);
setStatus(setDVDStatus);
setDirector(setDVDDirector);
setStudio(setDVDStudio);
setProducer(setDVDProducer);
}
void PrintDetails()
{
cout << "Title: " << getTitle() << endl;
cout << "Author: " << getAuthor() << endl;
cout << "Release Date: " << getReleaseDate() << endl;
cout << "Copyrite: " << getCopyright() << endl;
cout << "Genre: " << getGenre() << endl;
cout << "Status: " << getStatus() << endl;
cout << "Running Time: " << getRunningTime() << endl;
cout << "Director: " << getDirector() << endl;
cout << "Studio: " << getStudio() << endl;
cout << "Producer: " << getProducer() << endl;
}
private:
DVD();
int RunningTime;
string Director;
string Studio;
string Producer;
};
仮想 void setDetails(); に問題があります。
Book クラスと DVD クラスの両方に、詳細を設定するための setDetails というメソッドが必要です。問題は、Book クラスと DVD クラスの両方がこのメソッドに対して異なる引数を持っていることです。
どうすればこれを達成できますか?
この問題を解決する最善の方法は何ですか?