I have run into this situation I find really tricky. I have 2 classes: time12 and time24 which maintain time on a 12 hr and 24 hr basis respectively. Both of them are supposed to have individual conversion functions to handle conversions to the other type. But if I declare time 12 first, then the “time24” in the prototype of the conversion function will be undefined as the time24 class will be declared later. So what do I do now? I can’t even only declare it inside and define it after the 2nd class. So now what?
class time12
{
operator time24() //time24 is undefined at this stage
{
}
};
class time24
{
};
Normally in c++ you have 2 types of files, .h and .cpp. Your .h file is your declaration, and .cpp is your definition.
Example:
convtime.h:
convtime.cpp: