ここに私のクラスコードがあります:
class LibItem
{
public:
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;
};
これを .h ファイルと .cpp ファイルに入れたいと思っています。以下のコードは正しいですか?
ライブラリアイテム.cpp:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "LibItem.h"
virtual void LibItem::PrintDetails() = 0;
void LibItem::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 LibItem::setTitle(string TitleName)
{
Title = TitleName;
}
string LibItem::getTitle()
{
return Title;
}
void LibItem::setReleaseDate(string date)
{
ReleaseDate = date;
}
string LibItem::getReleaseDate()
{
return ReleaseDate;
}
void LibItem::setAuthor(string AuthorName)
{
Author = AuthorName;
}
string LibItem::getAuthor()
{
return Author;
}
void LibItem::setCopyright(string CopyrightDetails)
{
Copyright = CopyrightDetails;
}
string LibItem::getCopyright()
{
return Copyright;
}
void LibItem::setGenre(string GenreDetails)
{
Genre = GenreDetails;
}
string LibItem::getGenre()
{
return Genre;
}
void LibItem::setStatus(string StatusDetails)
{
Status = StatusDetails;
}
string LibItem::getStatus()
{
return Status;
}
};
//---------------------------------------------------------------------------
#pragma package(smart_init)
LibItem.h
//---------------------------------------------------------------------------
#ifndef LibItemH
#define LibItemH
class LibItem
{
public:
virtual void PrintDetails();
void setDetails(string, string, string, string, string, string);
void setTitle(string);
void setReleaseDate(string);
string getReleaseDate();
void setAuthor(string);
string getAuthor();
void setCopyright(string);
string getCopyright();
void setGenre(string);
string getGenre();
void setStatus(string);
string getStatus();
private:
string Title;
string ReleaseDate;
string Author;
string Copyright;
string Genre;
string Status;
};
//---------------------------------------------------------------------------
#endif
次に、この .h および .cpp ファイルをメイン関数で使用したい場合、これを行うために必要なコードは何ですか? 必要な include ステートメントは何ですか?