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 address (or which address to point to) printer = &Serial2; //this is the equivalent of Serial2.print printer->print("print using the Serial2 object");
Passing by reference & or * will increase performance when using datatypes that are larger than 8bit.
|Part of AlphaBeta Resources.|
|Last Modified:||December 26, 2015, at 11:24 PM|