I don't understand how this function can work because, you have to pass variable not by reference but by value to it (function make copy of variable), so how on earth this function can change variable f?
float f = 0.00f; //Variable to store data read from EEPROM.
int eeAddress = 0; //EEPROM address to start reading from
EEPROM.get( eeAddress, f );
Serial.println( f, 3 ); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float.
I don't understand how this function can work because, you have to pass variable not by reference but by value to it (function make copy of variable), so how on earth this function can change variable f?
Is it not the function definition rather than the function call that determines whether the value is passed by value or reference ? If so, then looking at
RayLivingston:
Look at the source code for EEPROM.get(). The second argument IS a reference.
Oh, so you can do it like that? This is really confusing, I am good only at C not C++. Because something like
void function(someType &var) in C will throw error.