views:

241

answers:

2

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
+5  A: 

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

AProgrammer
+6  A: 

namespace of deque is not define

std::deque<MotorPoint> motorPlotData;

or

using namespace std;
// ...

deque<MotorPoint> motorPlotData;
Phong
Doh, sillty! Thanks a lot!
Paul
std::deque<MotorPoint> is the better idea, as putting a namespace using-directive in a header file increases the potential for name conflicts in the files that include it.
ceo
@ceo:+1, I totally agree with you, but When you are working with mainly one namespace library, it can increase the readability of your code. There is also an alternative: **using std::deque;**
Phong