I am using C++ Builder. I have coded two classes in a console application and I want to use these classes in a VCL form application.
How do I do this? Do I have to split them into .cpp and .h files and then include them? Or is there another way?
UPDATE
Here is my code:
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;
};
I know that with strings, the following is used in .cpp files:
const std::string& exampleString
Is the same context used when talking about TDateTime data types? If so, can you please give me an example of how to use them?
It is hard to say without seeing how they are integrated within your code but certainly there is no harm in creating separate source and header files for each class and including them in the new project. You can then use those same files included within your existing console application also. It is certainly not a bad practice to do this.