-1

What does this bit of code do?

EERef( const int index )
        : index( index ) {}

It's inside a struct such as this...

/***
EERef class.

This object references an EEPROM cell.
Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM.
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
***/

struct EERef{

EERef( const int index )
    : index( index ) {}

//Access/read members.
uint8_t operator*() const
{ 
    return eeprom_read_byte( (uint8_t*) index ); 
}
operator const uint8_t() const       
{ 
    return **this; 
}

..... etc....

I've totally forgotten my C++. Someone jog my memory please?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
nvkris
  • 1

1 Answers1

0

What does this bit of code do?

EERef( const int index ) : index( index ) {}

That particular line of code is a constructor for struct EERef that takes a parameter and initializes the index member of EERef with the parameter value.

For reference: Constructors and Initializer Lists

Community
  • 1
  • 1
Jonathon Ogden
  • 1,562
  • 13
  • 19