例子

// here normal pointer
P* ptr = new P; // usual pointer allocated on heap
P& nat = *ptr; // object on heap bind to native object //.. here CLI managed
MO^ mngd = gcnew MO; // allocate on CLI heap
MO% rr = *mngd; // object on CLI heap reference to gc-lvalue

解释:在C++/CLI中,^指向托管的对象,对象的内存回收由CLR垃圾回收器自动管理,当然我们也可以用*来创建手动管理内存对象。

参考几个Stackoverflow上的答案:

It means that this is a reference to a managed object vs. a regular C++ pointer. Objects behind such references are managed by the runtime and can be relocated in the memory. They are also garbage-collected automatically.

When you allocated managed memory, that memory can be moved around by the garbage collector. The ^ operator is a pointer for managed memory, that continues to point to the correct place even if the garbage collector moves the object it points to.

最新文章

  1. 冰冻三尺非一日之寒--web框架Django
  2. 第23章 排序算法(包括merge等)
  3. jQuery动态加载脚本 $.getScript();
  4. 使用 Override 和 New 关键字进行版本控制
  5. C++ “读取位置 0x****** 时发生访问冲突”的可能原因
  6. linux和MAC下静态库.a文件合并
  7. Python学习笔记——几种数据类型
  8. [SQL学习笔记][用exists代替全称量词 ]
  9. [C#参考]主线程和子线程之间的参数传递
  10. 转:C++中引用传递与指针传递区别
  11. bootstrap datatable项目封装支持单选多选
  12. 矩阵快速幂---BestCoder Round#8 1002
  13. webApi签名验证
  14. multipath多路径实验02-配置多路径软件
  15. 小账本APP——软件项目风险管理及解决办法案例
  16. Protege4.3 添加Rules 栏
  17. CentOS6/7快捷使用gcc5
  18. std::string 用法总结
  19. 会话的保持和form表单
  20. HTML语言和CSS开发

热门文章

  1. SpringBoot(七) - Redis 缓存
  2. springboot项目中使用shiro实现用户登录以及权限的验证
  3. 齐博x1齐博首创钩子的使用方法
  4. win10操作系统下Android环境配置
  5. VS使用正则表达式删除程序中的空行
  6. Sqlite 安装操作使用
  7. MindSpore Graph Learning
  8. Python图像处理丨5种图像处理特效
  9. DevExpress中GridControl控件焦点改变时触发事件
  10. 使用c#的 async/await编写 长时间运行的基于代码的工作流的 持久任务框架