gpt4 book ai didi

c++ - 用户自定义结构的双端队列

转载 作者:太空狗 更新时间:2023-10-29 23:29:19 24 4
gpt4 key购买 nike

我有一个用户定义的结构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 ‘<’ 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

最佳答案

双端队列的命名空间没有定义:

std::deque<MotorPoint> motorPlotData;

using namespace std;
// ...

deque<MotorPoint> motorPlotData;

关于c++ - 用户自定义结构的双端队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2326376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com