【发布时间】:2015-03-30 09:17:46
【问题描述】:
问题解决了!感谢您的帮助。
我正在为我的程序编写调度程序。我有 2 个课程:task_timepoint 和 task_period。 task_period 是 task_timepoint 的派生类。
我为task_timepoint 编写了构造函数,但是当我开始为task_period 编写构造函数时,我遇到了无法解决的错误。
scheduler.hpp:
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include "boost/date_time/posix_time/posix_time.hpp"
#include <functional>
#include <chrono>
namespace schelduler{
using namespace schelduler;
using namespace boost::posix_time;
class task_timepoint{
protected:
ptime run_time; //Time at(after) that task_function should run
std::function<void(void)> task_function; //Function that should be run at specified time
public:
task_timepoint(ptime run_time, std::function<void(void)> task_function);
};
class task_period : public task_timepoint{
private:
time_duration run_period;
public:
task_period(time_duration run_period, std::function<void(void)> task_function);
};
}
#endif
scheduler.cpp:
#include "scheduler.hpp"
using namespace schelduler;
using namespace boost::posix_time;
task_timepoint::task_timepoint(ptime run_time, std::function<void(void)> task_function)
{
task_timepoint::run_time = run_time;
task_timepoint::task_function = task_function;
}
task_period::task_period(time_duration run_period, std::function<void(void)> task_function)
{
this->run_period = run_period;
//task_period::task_function = task_function;
}
错误:
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp: In constructor ‘schelduler::task_period::task_period(boost::posix_time::time_duration, std::function<void()>)’:
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp:12:91: error: no matching function for call to ‘schelduler::task_timepoint::task_timepoint()’
task_period::task_period(time_duration run_period, std::function<void(void)> task_function)
^
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp:12:91: note: candidates are:
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp:6:1: note: schelduler::task_timepoint::task_timepoint(boost::posix_time::ptime, std::function<void()>)
task_timepoint::task_timepoint(ptime run_time, std::function<void(void)> task_function)
^
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp:6:1: note: candidate expects 2 arguments, 0 provided
In file included from /home/dm3ch/Workspace/Refregiration_Telemetry/Device/src/scheduler.cpp:1:0:
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/include/scheduler.hpp:12:11: note: schelduler::task_timepoint::task_timepoint(const schelduler::task_timepoint&)
class task_timepoint{
^
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/include/scheduler.hpp:12:11: note: candidate expects 1 argument, 0 provided
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/include/scheduler.hpp:12:11: note: schelduler::task_timepoint::task_timepoint(schelduler::task_timepoint&&)
/home/dm3ch/Workspace/Refregiration_Telemetry/Device/include/scheduler.hpp:12:11: note: candidate expects 1 argument, 0 provided
make[2]: *** [CMakeFiles/Refregiration_Telemetry-Device.dir/src/scheduler.cpp.o] Error 1
make[1]: *** [CMakeFiles/Refregiration_Telemetry-Device.dir/all] Error 2
make: *** [all] Error 2
对不起我的英语不好
【问题讨论】:
-
"task_period 是 task_period 的派生类。" !!??!?!
-
编辑您的问题并在此处发布相关代码和错误。
-
我根本不会关注任何指向小示例的外部链接!请在此处发布您的代码,并告诉我们您收到了哪些错误消息。
标签: c++ class compiler-errors