I have written a clock class, with an international clock derived class. I am having problems with the syntax for the constructors in the derived class.
Here is what I've got in the .h:
Code:
class clock
{
public:
clock();
clock(string name);
clock(int hours, int minutes, bool morning, string name);
void set_clock (int hour, int minute, bool morning, string name);
void set_clock (int hour, int minute, bool morning);
void advance (int minutes);
int conv_time_mins(int hour, int minute);
int get_hour() const;
int get_minutes() const;
bool is_morning() const;
void display_time();
private:
int _hours;
int _mins;
bool _morn;
string _name;
};
class iclock : public clock
{
public:
iclock();
iclock(int offset);
void set_clock (int hour, int minute, bool morning);
void set_clock (int hour, int minute, bool morning, string name, int offset);
private:
int _offset;
};
and here is the .cpp
Code:
clock::clock()
{
_hours = 0;
_mins = 0;
_morn = false;
_name.assign("");
}
clock::clock(string name)
{
_hours = 0;
_mins = 0;
_morn = true;
_name = name;
}
clock::clock(int hours, int minutes, bool morning, string name)
{
_hours = hours;
_mins = minutes;
_morn = morning;
_name = name;
}
iclock::iclock()
: clock()
{
_offset = 0;
}
iclock::iclock(int offset) : clock(string name)
{
_offset = offset;
}
iclock::iclock(int offset)
: clock(int hours, int minutes, bool morning, string name)
{
_offset = offset;
}
I am getting errors saying that there is no matching function call when I try to create an object of type iclock in my main, like this:
Code:
iclock tokyo("Tokyo", 9);
iclock cairo("Cairo", 2);
iclock london("London", 0);
iclock new_york("New York", -5);
iclock GMT("GMT", 0);
Any help with the syntax?
Brian