Question

I've got a user-defined structure struct theName and I want to make a deque of these structures (deque<theName> theVar). However when I try to compile I get this error:

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 ‘<’ token

Why can't I do it this way?

File: 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
Was it helpful?

Solution

The namespace of deque is not defined:

std::deque<MotorPoint> motorPlotData;

or

using namespace std;
// ...

deque<MotorPoint> motorPlotData;

OTHER TIPS

deque is in namespace std, so std::deque.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top