- -最近非常怀念c++的属性 上网一搜结果 哎不支持c++ 属性,只能用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;
   }
};

int main(int argc, char* argv[])
{
KeyValuePair
<int,int> c1;

c1.Old
=123;
cout
<<c1.Old;
}

相关文章:

  • 2021-11-01
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-07-07
猜你喜欢
  • 2021-07-02
  • 2021-09-11
  • 2022-12-23
相关资源
相似解决方案