我在使用arduino c和StandardCplusplus软件包时遇到问题。我正在尝试声明一个向量,但出现以下错误:
Node.h:26:错误:ISO C ++禁止声明无类型的“向量”
Node.h:26:错误:无效使用'::'
Node.h:26:错误:预期';'在'<'标记之前
在其他问题上,人们在这里或这里忘记了include或use 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
Run Code Online (Sandbox Code Playgroud)
谢谢
编辑:我正在使用arduino 1.5.5 ide编译器。
edit2:我删除了除矢量以外的所有内容,按注释产生:
/*
Node.h
*/
#ifndef Node_h …Run Code Online (Sandbox Code Playgroud) 我可能只是不理解文件读取器 api,但是
当我尝试运行时:
for (var i = 0, f1, f2; f1 = files[sorted_index[i]], f2 = files[sorted_index[i+1]]; i=i+2) {
var file_one;
var file_two;
if(f1.size < f2.size){
file_one = f1;
file_two = f2;
} else {
file_one = f2;
file_two = f1;
}
var file_one_contents;
var file_two_contents;
var reader = new FileReader();
reader.readAsText(file_one);
reader.onload = readSuccess;
function readSuccess(evt){
file_one_contents = evt.target.result;
}
var reader = new FileReader();
reader.readAsText(file_two);
reader.onload = readSuccess2;
function readSuccess2(evt2){
file_two_contents = evt2.target.result;
}
console.log(file_one_contents);
console.log(file_two_contents);
Run Code Online (Sandbox Code Playgroud)
控制台日志仅包含未定义的内容。该脚本的目标是读取两个 …
这两种方式初始化结构之间是否存在差异:
structVar = {}
Run Code Online (Sandbox Code Playgroud)
和
structVar = {0}
Run Code Online (Sandbox Code Playgroud)