[20050125]
#include <boost/smart_ptr.hpp>
#include <iostream>
using namespace std;
class display{
public:
display(){cout << "Start new a class display!" <<endl;}
~display(){cout << "Delete class display!" <<endl;}
};
int main()
{
{
boost::scoped_ptr<display> sp(new display());
}
cout << "-------"<< endl;
return 0;
}
测试结果:
Start new a class display!
Delete class display!
-------
博客展示了一段C++代码,包含对`boost/smart_ptr`和`iostream`的引用,定义了`display`类,在`main`函数中使用`boost::scoped_ptr`创建该类对象,最后输出创建和删除类的测试结果。

被折叠的 条评论
为什么被折叠?



