怎么判断一个标示符是变量名还是函数名(等的睡着了)
如何判断一个标示符是变量名还是函数名(等的睡着了)
如下式
__property int Min = { read = m_min; write = m_min };
__property bool Bol = { read = GetBol; write = SetBol };
当用宏定义来实现时如何判断read 或write后的标示符成员变量还是成员函数
模拟实现如下:
class A
{
private:
int m_min;
bool m_bol;
public:
bool GetBol()
{
return m_bol;
}
void SetBol(bool value)
{
m_bol = value;
}
class P_Min
{
public:
operator int ()
{
A* pThis = (A*)((const char*)(this));
return pThis->m_min;//GetMin();
};
int operator =(const int iValue)
{
A* pThis = (A*)((const char*)(this));
pThis->m_min = iValue;
return iValue;
}
}Min;
class P_Bol
{
public:
operator bool ()
{
A* pThis = (A*)((const char*)(this));
return pThis->GetBol();
};
bool operator =(const bool iValue)
{
A* pThis = (A*)((const char*)(this));
pThis->SetBol(iValue);
return iValue;
}
}Bol;
// __property int Min = { read = m_min; write = m_min };
// __property bool Bol = { read = GetBol; write = SetBol };
};
------解决方案--------------------
Google "typeinfo PropType"
------解决方案--------------------
如下式
__property int Min = { read = m_min; write = m_min };
__property bool Bol = { read = GetBol; write = SetBol };
当用宏定义来实现时如何判断read 或write后的标示符成员变量还是成员函数
模拟实现如下:
class A
{
private:
int m_min;
bool m_bol;
public:
bool GetBol()
{
return m_bol;
}
void SetBol(bool value)
{
m_bol = value;
}
class P_Min
{
public:
operator int ()
{
A* pThis = (A*)((const char*)(this));
return pThis->m_min;//GetMin();
};
int operator =(const int iValue)
{
A* pThis = (A*)((const char*)(this));
pThis->m_min = iValue;
return iValue;
}
}Min;
class P_Bol
{
public:
operator bool ()
{
A* pThis = (A*)((const char*)(this));
return pThis->GetBol();
};
bool operator =(const bool iValue)
{
A* pThis = (A*)((const char*)(this));
pThis->SetBol(iValue);
return iValue;
}
}Bol;
// __property int Min = { read = m_min; write = m_min };
// __property bool Bol = { read = GetBol; write = SetBol };
};
------解决方案--------------------
Google "typeinfo PropType"
------解决方案--------------------