Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deque of user-defined structures

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
like image 585
Paul Avatar asked Feb 14 '26 02:02

Paul


2 Answers

The namespace of deque is not defined:

std::deque<MotorPoint> motorPlotData;

or

using namespace std;
// ...

deque<MotorPoint> motorPlotData;
like image 79
Phong Avatar answered Feb 17 '26 06:02

Phong


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

like image 30
AProgrammer Avatar answered Feb 17 '26 05:02

AProgrammer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!