Erros with lack of default constructors and inheritance
We're dealing with inheritance and we've been asked to remove the default constructors. I've been looking for answers in 3 different books and online and how found nothing really helpful.
Quote:
GameEvent.cpp: In constructor ‘GameEvent::GameEvent(Time)’:
GameEvent.cpp:14: error: type ‘Time’ is not a direct base of ‘GameEvent’
GameEvent.cpp:14: error: no matching function for call to ‘Time::Time()’
Time.h:20: note: candidates are: Time::Time(int, int, double)
Time.h:13: note: Time::Time(const Time&)
GameEvent.h
Code:
#ifndef GAMEEVENT_H
#define GAMEEVENT_H
#include <string>
using namespace std;
#include "Time.h"
#include "Game.h"
class GameEvent {
protected:
Time time;
public:
// GameEvent();
GameEvent(const Time t);
Time getTime();
const virtual string toString() = 0;
};
#endif /*GAMEEVENT_H*/
Time.cpp
Code:
#ifndef TIME_H
#define TIME_H
#include <string>
using namespace std;
class Time {
private:
int period;
double seconds;
public:
/* Time(); */
Time(int p, int m, double s);
double difference(const Time& other) const;
bool operator<(Time& other);
const string toString();
bool operator==(Time& other);
static const int NORMAL_SECONDS = 60*15; //Fifteen minutes
static const int OVERTIME_SECONDS = 60*5; //Five minutes
};
ostream& operator<<(ostream& out, Time& other);
#endif /*TIME_H*/