Pointer Resource for Arduino Author: Alexander Brevig Contact: email@example.com
It enables the programmer to communicate directly to an already initialized instance of a datatype.
For instance, it might come in handy to have a class being able to swap which Serial object that does Serial communications. By using pointers this is possible.
#include "Print.h" //datatype* variablename = ⌖ Print* printer = &Serial;
//this is the equivalent of Serial.print printer->print("print using the Serial object"); //notice the -> as opposed to . //change target adress (or which adress to point to) printer = &Serial2; //this is the equivalent of Serial2.print printer->print("print using the Serial2 object");
Passing by referance & or * will increase performance when using datatypes that are larger than 8bit.
|Part of AlphaBeta Resources.|
|Last Modified:||September 11, 2014, at 02:09 PM|