struct Bar // definition of a struct
{
Bar(int i, int y=0) : i(i + i), y(y) {}
int i;
int y;
};
enum struct Color : byte {red, green = 2, blue};
void setup() {
Serial.begin(115200);
// Bar myBar; // Error! No initializer
Bar Bar(1);
struct Bar Bar2(2,6); // elaborated type
Serial.println("Bar1");
Serial.print("Wert i: ");Serial.println(Bar.i);
Serial.print("Wert y: ");Serial.println(Bar.y);
Serial.println("\nBar2");
Serial.print("Wert i: ");Serial.println(Bar2.i);
Serial.print("Wert y: ");Serial.println(Bar2.y);
Color col = Color::green;
switch (col) {
case Color::red: Serial.println("Rot"); break;
case Color::green: Serial.println("Grün"); break;
case Color::blue: Serial.println("Blau"); break;
default: break;
}
}
void loop() { }