在路上.......分享 http://blog.sciencenet.cn/u/longxie1983 一念嗔心起,百万障门开

博文

VC++.net 中为类添加“属性(property)”

已有 4937 次阅读 2012-11-26 14:11 |个人分类:我的工作|系统分类:科研笔记|关键词:学者| property

C#中可以很容易的为类添加属性,比如

//cs code
class Person 
{
 private string myName ="N/A"; 
 public string Name 
 { 
     get { return myName; } 
     set { myName = value; }
 }
}

可是C++.net如果去添加,介绍的文章似乎不多,刚刚用到了,记录一下,主要是使用微软添加的新关键字
 property

//c++ code
class Person
     public: 
        property String^ Name    
        {
               String^ get(void)          { return myName; };
               void set(String^ value)          { myName = value; };
        } 
     private: 
              String^ myName ="N/A";
}


https://m.sciencenet.cn/blog-483379-636371.html

上一篇:VC++ .net 中使用 dao
下一篇:用freeSSHd架设ssh服务器,但是不支持scp

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-18 14:35

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部