- -最近非常怀念c++的属性 上网一搜结果 哎不支持
,只能用c++进行扩展汗死死死
“__declspec”是Microsoft c++中专用的关键字,它配合着一些属性可以对标准C++进行扩充。这些属性有:
align、allocate、deprecated、dllexport、dllimport、 naked、noinline、noreturn、nothrow、novtable、selectany、thread、property和uuid。
KeyValuePair
{
private:
//-- 参数
T1 *Key;
//------值
T2 *Value;
public
:
KeyValuePair()
{
Key=new T1;
Value=new T2;
}
~KeyValuePair()
{
delete Key;
delete Value;
}
public :
T1 GetKey()
{
return this->Key;
}
T1 SetKey(T1 inputKey)
{
this->Key=inputKey;
}
private :
int m_old;
public:
//---------属性----get--------set--------返回数据---属性名称
_declspec(property(get=GetOld,put=SetOld))int Old;
int GetOld(void)
{
return m_old;
}
void SetOld(int value)
{
m_old=value;
}
};
“__declspec”是Microsoft c++中专用的关键字,它配合着一些属性可以对标准C++进行扩充。这些属性有:
align、allocate、deprecated、dllexport、dllimport、 naked、noinline、noreturn、nothrow、novtable、selectany、thread、property和uuid。
{
private:
//-- 参数
T1 *Key;
//------值
T2 *Value;
public
:
KeyValuePair()
{
Key=new T1;
Value=new T2;
}
~KeyValuePair()
{
delete Key;
delete Value;
}
public :
T1 GetKey()
{
return this->Key;
}
T1 SetKey(T1 inputKey)
{
this->Key=inputKey;
}
private :
int m_old;
public:
//---------属性----get--------set--------返回数据---属性名称
_declspec(property(get=GetOld,put=SetOld))int Old;
int GetOld(void)
{
return m_old;
}
void SetOld(int value)
{
m_old=value;
}
};
int main(int argc, char* argv[])
{
KeyValuePair<int,int> c1;
c1.Old=123;
cout<<c1.Old;
}
{
KeyValuePair<int,int> c1;
c1.Old=123;
cout<<c1.Old;
}