我正在使用 C++ 生成器。我在控制台应用程序中编写了两个类,我想在 VCL 表单应用程序中使用这些类。
我该怎么做呢?我是否必须将它们拆分为 .cpp 和 .h 文件,然后包含它们?还是有其他方法?
更新
这是我的代码:
class appointment
{
public:
appointment();
appointment(string aName, TDateTime aDate, TDateTime aReminderDateTime, string aType,
string aLocation, string aComments, bool aIsImportant)
{
appName = aName;
appDateTime = aDate;
appReminderDateTime = aReminderDateTime;
appType = aType;
appLocation = aLocation;
appComments = aComments;
appIsImportant = aIsImportant;
}
void setAppName(string aName)
{
appName = aName;
}
void setAppDateTime(TDateTime aDateTime)
{
appDateTime = aDateTime;
}
void setappReminderDateTime(TDateTime aReminderDateTime)
{
appReminderDateTime = aReminderDateTime;
}
void printAppointmentDetails()
{
cout << "Appintment Date: " << appDateTime << endl;
cout << "Appintment Reminder Date: " << appReminderDateTime << endl;
cout << "Appintment Type: " << appType << endl;
cout << "Appintment Location: " << appLocation << endl;
cout << "Appintment Comments: " << appComments << endl;
if (appIsImportant)
{
cout << "Appintment IsImportant: " << "Yes" << endl;
} else {
cout << "Appintment IsImportant: " << "No" << endl;
}
}
void setAppType(string aType)
{
appType = aType;
}
void setAppLocation(string aLocation)
{
appLocation = aLocation;
}
void setAppComments(string aComments)
{
appComments = aComments;
}
void setAppIsImportant(bool aIsImportant)
{
appIsImportant = aIsImportant;
}
string getAppName()
{
return appName;
}
TDateTime getAppDateTime()
{
return appDateTime;
}
TDateTime getAppReminderDateTime()
{
return appReminderDateTime;
}
string getAppType()
{
return appType;
}
string getAppLocation()
{
return appLocation;
}
string getAppComments()
{
return appComments;
}
bool getAppIsImportant()
{
return appIsImportant;
}
private:
//appointment();
string appName;
TDateTime appDateTime;
TDateTime appReminderDateTime;
string appType;
string appLocation;
string appComments;
bool appIsImportant;
//person owner;
};
我知道对于字符串,在 .cpp 文件中使用以下内容:
const std::string& exampleString
谈论 TDateTime 数据类型时是否使用相同的上下文?如果是这样,你能给我一个如何使用它们的例子吗?