【发布时间】:2012-06-11 10:34:31
【问题描述】:
我知道这个问题已经被问过很多次了,但我无法理解这个问题。这是我的头文件:
#ifndef TASK_H
#define TASK_H
#include "storage_adaptors.hpp"
#include <boost/numeric/ublas/vector.hpp>
class Task {
private:
boost::numeric::ublas::vector<double> taskPosistionConstraint;
boost::numeric::ublas::vector<double> initialPosition;
boost::numeric::ublas::vector<double> finalPosition;
double pathLength;
int taskType;
public:
Task();
Task(double* _initialPoint, double* _finalPoint, int type);
double getLength();
int getTaskType();
~Task();
};
#endif /* TASK_H */
这是cpp文件:
#include "Task.h"
const int TASK_SIZE = 3;
Task::Task() {
}
Task::~Task() {
}
Task::Task(double* _initialPoint, double* _finalPoint, int type) {
finalPosition = make_vector_from_pointer(TASK_SIZE,_finalPoint);
initialPosition = make_vector_from_pointer(TASK_SIZE, _initialPoint);
}
错误发生在storage_adaptors.hpp 中定义的make_vector_from_pointer 函数中,该函数包含在Task.h 中,这是一个boost hpp file。
如果将标头添加到类头文件中,为什么我会出现超出范围的错误:
Task.cpp:21:错误:“make_vector_from_pointer”未在 这个范围
【问题讨论】:
-
boost::numeric::ublas::make_vector_from_pointer或using namespace boost::numeric::ublasincpp -
你能告诉我们缺少的声明吗?
-
另外,拥有一个“Task”类和一个“Task”方法并不是一个好主意
-
@maverik,但是,在那个头文件中,已经添加了命名空间。我应该自己再做一次吗?
-
@Filip,是类的构造函数。