lundi 26 mars 2018

C++ pure virtual error

I am trying to inherit from an abstract class but getting the following errors:

n file included from / usr / include / c++/5/vector: 64: 0, from / usr / include / boost / format.hpp: 17, from / usr / include / boost / math / policies / error_handling.hpp: 31, from / usr / include / boost / math / special_functions / round.hpp: 14, from / opt / ros / kinetic / include / ros / time.h: 58, from / opt / ros / kinetic / include / ros / ros.h: 38, from / home / gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 4, from / home / gil / catkin_ws / src / indoor_mission_manager / src / Tasks / Task.cpp: 1: /usr/include / c++/5/bits / stl_vector.h: 713: 7: error: invalid abstract parameter type‘ indoor_mission_manager::Task’ resize(size_type __new_size, value_type __x = value_type()) ^ In file included from / home / gil / catkin_ws / src / indoor_mission_manager / src / Tasks / Task.cpp: 1: 0: /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 8: 7: note: because the following virtual functions are pure within‘ indoor_mission_manager::Task’: class Task ^ /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 11: 16: note: virtual void indoor_mission_manager::Task::Execute() virtual void Execute() = 0; ^ In file included from / usr / include / c++/5/vector: 64: 0, from / usr / include / boost / format.hpp: 17, from / usr / include / boost / math / policies / error_handling.hpp: 31, from / usr / include / boost / math / special_functions / round.hpp: 14, from / opt / ros / kinetic / include / ros / time.h: 58, from / opt / ros / kinetic / include / ros / ros.h: 38, from / home / gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 4, from / home / gil / catkin_ws / src / indoor_mission_manager / include / Tasks / RootTask.h: 10, from / home / gil / catkin_ws / src / indoor_mission_manager / src / Tasks / RootTask.cpp: 8: /usr/include / c++/5/bits / stl_vector.h: 713: 7: error: invalid abstract parameter type‘ indoor_mission_manager::Task’ resize(size_type __new_size, value_type __x = value_type()) ^ In file included from / home / gil / catkin_ws / src / indoor_mission_manager / include / Tasks / RootTask.h: 10: 0, from / home / gil / catkin_ws / src / indoor_mission_manager / src / Tasks / RootTask.cpp: 8: /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 8: 7: note: because the following virtual functions are pure within‘ indoor_mission_manager::Task’: class Task ^ /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 11: 16: note: virtual void indoor_mission_manager::Task::Execute() virtual void Execute() = 0; ^ indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / build.make: 110: recipe for target 'indoor_mission_manager/CMakeFiles/indoor_mission_manager.dir/src/Tasks/Task.cpp.o' failed make[2]: * * * [indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / src / Tasks / Task.cpp.o] Error 1 make[2]: * * * Waiting for unfinished jobs.... indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / build.make: 158: recipe for target 'indoor_mission_manager/CMakeFiles/indoor_mission_manager.dir/src/Tasks/RootTask.cpp.o' failed make[2]: * * * [indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / src / Tasks / RootTask.cpp.o] Error 1 In file included from / usr / include / c++/5/vector: 64: 0, from / usr / include / boost / format.hpp: 17, from / usr / include / boost / math / policies / error_handling.hpp: 31, from / usr / include / boost / math / special_functions / round.hpp: 14, from / opt / ros / kinetic / include / ros / time.h: 58, from / opt / ros / kinetic / include / ros / ros.h: 38, from / home / gil / catkin_ws / src / indoor_mission_manager / src / indoor_mission_action_server.cpp: 9:
/usr/include / c++/5/bits / stl_vector.h: 713: 7: error: invalid abstract parameter type‘ indoor_mission_manager::Task’ resize(size_type __new_size, value_type __x = value_type()) ^ In file included from / home / gil / catkin_ws / src / indoor_mission_manager / include / Tasks / RootTask.h: 10: 0, from / home / gil / catkin_ws / src / indoor_mission_manager / src / indoor_mission_action_server.cpp: 16: /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 8: 7: note: because the following virtual functions are pure within‘ indoor_mission_manager::Task’: class Task ^ /home/gil / catkin_ws / src / indoor_mission_manager / include / Tasks / Task.h: 11: 16: note: virtual void indoor_mission_manager::Task::Execute() virtual void Execute() = 0; ^ indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / build.make: 62: recipe for target 'indoor_mission_manager/CMakeFiles/indoor_mission_manager.dir/src/indoor_mission_action_server.cpp.o' failed make[2]: * * * [indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / src / indoor_mission_action_server.cpp.o] Error 1 CMakeFiles / Makefile2: 1885: recipe for target 'indoor_mission_manager/CMakeFiles/indoor_mission_manager.dir/all' failed make[1]: * * * [indoor_mission_manager / CMakeFiles / indoor_mission_manager.dir / all] Error 2 Makefile: 138: recipe for target 'all' failed make: * * * [all] Error 2

Not sure what am i missing... Here are my H and CPP files:

RootTask.cpp

#include "Tasks/RootTask.h"
namespace manager {
  RootTask::RootTask(std::string name) {
    mTaskName = name;
  }
  RootTask::~RootTask() {}
  RootTask::RootTask() {}

  void RootTask::Execute() {}

  void RootTask::setTaskSeqByName() {}
  std::string RootTask::GetTaskName() {
    return mTaskName;
  }
}

RootTask.h

#include "Tasks/Task.h"
namespace manager {
  class RootTask: public Task {
    public:

      RootTask();
    RootTask(std::string name);~RootTask();

    void Execute();
    void setTaskSeqByName();
    std::string GetTaskName();
  };
}

Task.cpp

#include "Tasks/Task.h"
#include < iostream >

  namespace manager {
    void Task::Stop() {}
    void Task::Pause() {}
    void Task::OnError() {}
    std::string Task::GetTaskName() {}
    void Task::setTaskSeqByName() {}
  }

Task.h

#pragma once

#include < iostream > 
#include "ros/ros.h"

namespace manager {
  class Task {
    public:
      virtual void Execute() = 0;
    virtual void setTaskSeqByName();
    virtual void Stop();
    virtual void Pause();
    virtual void OnError();
    virtual std::string GetTaskName();

    protected:
      std::string mTaskName;
    std::vector < Task > mTaskSequence;
  };
}

Thank you for the assistance.

Aucun commentaire:

Enregistrer un commentaire