I'm in the process of trying to convert a C program using struct
s into C++ with class
es. I am trying to call a member function of a class B
from within class A
. Here is a snippet to explain my error:
class Time{
public:
Time();
Time(int hour, int minute);
int time_Equal(Time &a, Time &b) const;
-----
private:
int hour;
int minute;
};
Boolean Time::time_Equal(Time &a, Time &b) const
{
/* If hour of Time "a" equals hour of Time "b" */
if(a.hour == b.hour){
if(a.minute == b.minute)
return TRUE;
}
}
class DaTime{
public:
DaTime();
DaTime(Day day, Time start, Time end);
Boolean dt_Equal(DaTime &a, DaTime &b) const;
private:
int duration;
Time start;
Time end;
};
Boolean DaTime::dt_Equal(DaTime &a, DaTime &b) const
{
if(time_Equal(a.start, b.start)){
if(time_Equal(b.end, a.end))
return TRUE;
}
else
return FALSE;
}
The error I am getting is that time_Equal
is not declared in this scope. The reason I do not understand this is because I have included a header file where Time
is declared before DaTime
. I don't see the issue with how I have declared the functions.