编辑
这是我的新代码:
class LibItem
{
public:
//LibItem();
//LibItem(string setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus)
//{
// Title = setItemTitle;
// Author = setItemAuthor;
// ReleaseDate = setItemReleaseDate;
// Copyright = setItemCopyright;
// Genre = setItemGenre;
// Status = setItemStatus;
//}
//~LibItem(); //DO ******************
virtual void PrintDetails() = 0;
void setDetails(string setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus)
{
Title = setItemTitle;
Author = setItemAuthor;
ReleaseDate = setItemReleaseDate;
Copyright = setItemCopyright;
Genre = setItemGenre;
Status = setItemStatus;
}
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 setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus, string setItemISBN)
{
setDetails(setItemTitle, setItemAuthor, setItemReleaseDate, setItemCopyright, setItemGenre, setItemStatus);
setISBN(setItemISBN);
}
void setISBN(string ISBNDetails)
{
ISBN = ISBNDetails;
}
string getISBN()
{
return ISBN;
}
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();
string ISBN;
};
class DVD : public LibItem
{
public:
DVD(string setItemTitle, string setItemAuthor, string setItemReleaseDate, string setItemCopyright, string setItemGenre, string setItemStatus, int setItemRunningTime, string setItemDirector, string setItemStudio, string setItemProducer)
{
setDetails(setItemTitle, setItemAuthor, setItemReleaseDate, setItemCopyright, setItemGenre, setItemStatus);
setRunningTime(setItemRunningTime);
setDirector(setItemDirector);
setStudio(setItemStudio);
setProducer(setItemProducer);
}
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 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;
};
这是我使用上述类的代码:
LibItem *test;
test = new DVD("TestDVD","Test Author","01-01-2012","TestCopyright","TestGenre","TestStatus","120","TestDirector","TestStudio","TestProducer");
test->PrintDetails();
我收到此错误:
[BCC32 错误] 问题 5.cpp(200): E2285 找不到匹配 'DVD::DVD(const char *,const char *,const char *,const char *,const char *,const char *,const char *,const char *,const char *,const char *)'
我能否提供一些有关为什么会发生此错误以及如何修复它的信息?