首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

【Poco】Poco:AutoReleasePool的事例

2012-11-25 
【Poco】Poco::AutoReleasePool的例子#include ../tmain.hppnamespace{class TestObj{public:TestObj(): _

【Poco】Poco::AutoReleasePool的例子

#include "../tmain.hpp"namespace{class TestObj{public:TestObj(): _rc(1){++_count;}void duplicate(){++_rc;}void release(){if (--_rc == 0)delete this;}int rc() const{return _rc;}static int count(){return _count;}protected:~TestObj(){--_count;}private:int _rc;static int _count;};int TestObj::_count = 0;}void test_AutoReleasePool(){Poco::AutoReleasePool<TestObj> arp;arp.add(new TestObj);arp.add(new TestObj);arp.add(new TestObj);arp.add(new TestObj);assert (TestObj::count() == 4);arp.release();assert (TestObj::count() == 0);}


热点排行