Useful Language Features

Arduino

Last Update Unknown

C++ Arrays

  • Arrays are defined with [ ] after the name
  • They can have const or non-const array types
  • We use the index to access elements of the array, starting at 0 (rather than 1)


C++ Enum Types

We tend to use UpperCamelName for the enum-type and ALL_UPPER_SNAKE_CASE for the member-names.


An enum defines a type so it doesn't use an equals sign!!


Each member-name represents a const int i.e. 0,1,2,3... etc

This can be used to index arrays or for switch case labels.



C++ Switch

A switch is a much nicer way of writing an if - else if - else-if - else-if ... statement