【发布时间】:2014-01-28 22:11:44
【问题描述】:
我在使用 arduino c 和 StandardCplusplus 包时遇到问题。我正在尝试声明一个向量,但出现以下错误:
Node.h:26: 错误:ISO C++ 禁止声明没有类型的“向量”
Node.h:26:错误:'::' 的使用无效
Node.h:26: 错误:预期 ';'before '
看其他问题,here 或 here 人忘记了 include 或使用 std,但我都做了。
/*
Node.h
*/
#ifndef Node_h
#define Node_h
#include "Arduino.h"
#include <StandardCplusplus.h>
#include <vector>
#include <string>
#include <iterator>
class Node
{
public:
Node(int size);
~Node();
float bias();
void set_bias(float);
void print();
void fprint(FILE *);
float compute(std::vector<float> inputs);
void setWeights(std::vector<float> inws);
void set_weight(int,float);
float dutyCycle();
protected:
std::vector<float> _weights; //input weights:30
float level;
void init(int size);
std::vector<int> firelog;
};
#endif
谢谢
编辑:我使用的是 arduino 1.5.5 ide 编译器。
edit2:我已经根据 cmets 删除了除矢量以外的所有内容:
/*
Node.h
*/
#ifndef Node_h
#define Node_h
#include <vector>
class Node
{
public:
Node();
~Node();
std::vector<int> test;
};
#endif
仍然输出错误:
在 Node.cpp:1 中包含的文件中:
Node.h:13: 错误:ISO C++ 禁止声明没有类型的“向量”
Node.h:13: 错误:'::' 的使用无效
Node.h:13: 错误: 预期 ';'在'之前
【问题讨论】:
-
命名约定不一致是怎么回事?
set_weight和setWeights... -
保留下划线开头的名称,如果有记忆的话。但这可能不是。
-
这个ideone example 似乎工作正常。有什么我们没有在这里看到的吗?
-
这个头文件#include
在这里做什么?! -
错误在包含的标头中并且错误消息被剥离:-1