// A global data item can normally be initialized only once in an EXE or DLL project. selectany can be used in initializing global data defined by headers,
// when the same header appears in more than one source file. that means you can instance one static variable in the .h.
// in file "CSeekMode.h"
class SeekMode
{
public:
static SeekMode Begin;
static SeekMode Current;
static SeekMode End;
operator int() const { return this->m_iValue; }
bool operator == (const SeekMode& other) const { return this->m_iValue == other.m_iValue; }
bool operator != (const SeekMode& other) const { return this->m_iValue == other.m_iValue; }
{
public:
static SeekMode Begin;
static SeekMode Current;
static SeekMode End;
operator int() const { return this->m_iValue; }
bool operator == (const SeekMode& other) const { return this->m_iValue == other.m_iValue; }
bool operator != (const SeekMode& other) const { return this->m_iValue == other.m_iValue; }
// Copy construction.
SeekMode(const SeekMode& other = SeekMode::Begin) { this->m_iValue = other.m_iValue; }
private:
SeekMode(int iValue) { this->m_iValue = iValue; }
int m_iValue;
};
__declspec(selectany) SeekMode SeekMode::Begin(0);
__declspec(selectany) SeekMode SeekMode::Current(1);
__declspec(selectany) SeekMode SeekMode::End(2);
SeekMode(const SeekMode& other = SeekMode::Begin) { this->m_iValue = other.m_iValue; }
private:
SeekMode(int iValue) { this->m_iValue = iValue; }
int m_iValue;
};
__declspec(selectany) SeekMode SeekMode::Begin(0);
__declspec(selectany) SeekMode SeekMode::Current(1);
__declspec(selectany) SeekMode SeekMode::End(2);
//

沒有留言:
張貼留言