自從我編寫任何C++以來,我只是試圖製作一個簡單的程序來複制不同類型的時鐘來刷新我的記憶。另一個'成員聲明未找到'
我已經開始編寫一個Clock
超類,並且獲得了除構造函數/析構函數以外的每種方法的Member declaration not found
。我認爲這是一個小錯誤,但我什麼也找不到。
Clock.h
/*
* Clock.h
*/
#ifndef CLOCK_H_
#define CLOCK_H_
class Clock {
private:
int seconds;
int minutes;
int hours;
public:
Clock();
Clock(int, int, int);
virtual ~Clock();
virtual void tick() = 0;
void setTime(int, int, int);
void print();
};
#endif /* CLOCK_H_ */
Clock.cpp
/*
* Clock.cpp
*/
#include "Clock.h"
#include <iostream>
Clock::Clock() {
seconds = 0;
minutes = 0;
hours = 0;
}
Clock::Clock(int secs, int mins, int hrs) :
seconds(secs), minutes(mins), hours(hrs) {
}
Clock::~Clock() {
// TODO Auto-generated destructor stub
}
Clock::setTime(int secs, int mins, int hrs) {
seconds = secs;
minutes = mins;
hours = hrs;
}
Clock::print() {
std::cout << hours << ":" << minutes << ":" << seconds << std::endl;
}