boost::shared_ptr 的作为参数传递,以及构造细节!
来源:互联网 发布:淘宝宝贝描述模素材 编辑:程序博客网 时间:2024/06/10 15:22
代码如下:
#include <iostream>#include <boost/shared_ptr.hpp>#include <boost/make_shared.hpp>void funcx(boost::shared_ptr<int> c, int b) {std::cout << "after: " << "&c " << static_cast<void *>(&c) << ", "<< "c.get() " << static_cast<void *>(c.get()) << ", "<< "&b " << static_cast<void *>(&b) << std::endl;}int main(int argc, char *argv) {int a = 2;int b = 3;boost::shared_ptr<int> c = boost::make_shared<int>(a);std::cout << "first: " << "&c " << static_cast<void *>(&c) << ", " << "c.get() " << static_cast<void *>(c.get()) << ", "<< "&b " << static_cast<void *>(&b) << ", "<< "&a " << static_cast<void *>(&a) << std::endl;funcx(c, b);system("pause");return 1;}
输出结果如下:
first: &c 003FF988, c.get() 004B0A04, &b 003FF998, &a 003FF9A4
after: &c 003FF444, c.get() 004B0A04, &b 003FF44C
请按任意键继续. . .
阅读全文
0 0
- boost::shared_ptr 的作为参数传递,以及构造细节!
- 为何不要构造一个临时的shared_ptr作为函数参数
- 使用boost::shared_ptr做为线程的参数
- 派生类的构造函数定义以及参数传递
- 函数作为参数的传递
- 关于boost的shared_ptr以及weak_ptr的研究
- boost 库的 shared_ptr
- boost::shared_ptr的使用方法
- boost::shared_ptr的使用方法
- boost shared_ptr的使用方法
- boost::shared_ptr的使用方法
- Boost关于bind的使用以及函数对象和传递参数的问题
- 将函数作为参数传递/以及计算函数运行时间的函数的实现
- [转载]函数返回值为数组以及数组作为参数传递的问题
- 数组作为函数参数的传递
- .net对象作为参数传递的注意事项
- 数组作为函数的参数传递
- 数组作为参数传递的方式
- Unity3D 旋转矩阵 顶点动画
- 二分查找法
- shell执行linux命令
- 局域网内固定自己的ip
- Android中MVP架构模式详解
- boost::shared_ptr 的作为参数传递,以及构造细节!
- 在java程序中制作动图
- 任何通过github搭建个人网页
- ActiveMQ、RabbitMQ和Kafka的简单对比
- AAC(高级音频编码)帧格式及编码介绍
- ssm框架整合
- Python网络爬虫与信息提取-Day10-(实例)中国大学排名定向爬虫
- C/C++的编码转换
- HashMap与ConcurrentHashMap的区别