2

我有一个用户定义的结构struct theName,我想制作这些结构的双端队列(deque<theName> theVar)。但是,当我尝试编译时,出现此错误:

In file included from main.cpp:2:
Logger.h:31: error: ISO C++ forbids declaration of ‘deque’ with no type
Logger.h:31: error: expected ‘;’ before ‘&lt;’ token

为什么我不能这样做?

文件:Logger.h

#ifndef INC_LOGGER_H
#define INC_LOGGER_H

#include <deque>

#include "Motor.h"

struct MotorPoint {
        double speed;
        double timeOffset;
};

class Logger{
        private:
                Motor &motor;
                Position &position;
                double startTime;

(31)            deque<MotorPoint> motorPlotData;

                double getTimeDiff();
        public:
                Logger(Motor &m, Position &p);
                //etc...
};
#endif
4

2 回答 2

9

未定义 deque 的命名空间:

std::deque<MotorPoint> motorPlotData;

或者

using namespace std;
// ...

deque<MotorPoint> motorPlotData;
于 2010-02-24T13:48:34.900 回答
5

deque 在命名空间 std 中,所以 std::deque。

于 2010-02-24T13:48:17.380 回答