2016-04-23 80 views
-1

這段代碼做了什麼?Arduino EEProm.h代碼

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

這是一個結構裏面像這樣...

/*** 
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; 
} 

.....等等....

我已經完全忘記了我的C++。有人請記住我的記憶?

+0

請不要使用C標籤標記C++問題。 C標籤用於C語言問題。 –

+1

_「我完全忘記了我的C++。」然後拿起你的教科書並提醒你自己。有關Stack Overflow的問題需要事先研究。 –

回答

0

這段代碼做了什麼?

EERef(const int的指數):索引(索引){}

即特定的代碼行是struct EERef一個構造函數的參數,並初始化的EERef與參數值的index構件。

僅供參考:Constructors and Initializer Lists

+0

謝謝Jonathon! – nvkris