使用 Teensy 3.2,我的程序挂在下面指出的部分。我不知道如何访问glyph
。如果我注释掉该//hangs here
行,我可以看到所有行都打印到我的 Arduino 串行监视器上。
#include <vector>
#include <Arduino.h>
class Letter {
public:
String glyph = "a";
};
class Language {
public:
Language();
std::vector <Letter> alphabet;
};
Language::Language(){
std::vector <Letter> alphabet;
Letter symbol = Letter();
alphabet.push_back(symbol);
delay(2000);
Serial.println("hello world");//prints in the arduino monitor
Serial.println(this->alphabet[0].glyph);//hangs here
Serial.println("line of interest executed");//runs only if line above is commented out
}
void setup() {
Serial.begin(9600);
Language english = Language();
}
void loop() {
}