2016-04-23 79 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