class RefCounted{protected: RefCounted(){ m_ref_count = 0; } virtual ~RefCounted(){}public: void incRef() { ++m_ref_count; } void desRef()...
分类:
编程语言 时间:
2015-07-18 17:02:22
阅读次数:
190
在Application.mk 里增加-D__GLIBC__ 让项目支持boost增加-std=c++11 让项目支持c++11 (3.x的cocos本身已经支持了的)看起来这样:APP_STL := gnustl_staticAPP_CPPFLAGS := -frtti -DCC_ENABLE_C...
分类:
移动开发 时间:
2015-07-17 18:25:22
阅读次数:
190
假设有如下两个函数:int priority();void processWidget(std::tr1::shared_ptrpw, int priority);对processWidget的调用如下:processWidget(std::tr1::shared_ptrpw(new Widget....
分类:
编程语言 时间:
2015-07-17 18:17:30
阅读次数:
158
//模拟实现boost库下的scoped_array
#include
#include
using namespace std;
template
class scoped_array
{
private:
T * px;
scoped_array(scoped_array const &);
scoped_array& operator=(scoped_array const...
分类:
编程语言 时间:
2015-07-17 16:16:08
阅读次数:
118
//模拟实现boost下的scoped_ptr
#include
#include
using namespace std;
template
class scoped_ptr
{
private:
T * px;
scoped_ptr(scoped_ptr const &);
scoped_ptr& operator=(scoped_ptr const &);
void ...
分类:
编程语言 时间:
2015-07-17 12:01:02
阅读次数:
157
1 #include 2 #include 3 4 std::string exePath = boost::filesystem::initial_path().string();这样就可以了。避免用win32 API这种又不友好也不跨平台的方式了。直接用boost舒服。
分类:
其他好文 时间:
2015-07-16 13:36:36
阅读次数:
435
1 编译boost以 1.58.0 版本 boost 和VS2013为例当前解压路径 "D:\Libraries\boost_1_58_0"1) 打开VS2013命令提示符2) 运行bootstrap.bat注意全程不要关闭命令提示符, 所有操作均在此中完成3) 运行b2.exe 或bjam.exe...
本将主要介绍智能指针shared_ptr和unique_ptr,并简单实现基于引用计数的智能指针。 自C++11起,C++标准提供两大类型的智能指针: 1. Class shared_ptr实现共享式拥有(shared ownership)概念。多个智能指针可以指向相同对象,该对象和其相关资...
分类:
编程语言 时间:
2015-07-14 17:30:18
阅读次数:
254
在c++中,动态内存的管理是通过一对运算符来完成的:new,在动态内存中为对象分配空间并返回一个指向该对象的指针,我们可以选择对对象进行初始化;delete,接受一个动态对象指针,销毁该对象并释放与之关联的内存。
动态内存在使用时很容易出问题,有时会忘记释放内存,造成内存泄露,有时在尚有指针引用内存的情况下就释放了内存,导致产生引用非法内存的指针。
为了更容易(同时也更安全)第使用动态内存,新的...
分类:
其他好文 时间:
2015-07-14 11:31:29
阅读次数:
102
dev c++ 的boost库的安装步骤 然后点击“check for updates”按钮 最后点击“Download selected”按钮,下载完成后安装.... 给dev添加boost库文件,找到之前安装的目录#include #include#include#include#in...
分类:
编程语言 时间:
2015-07-12 21:35:23
阅读次数:
210