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

FUCK, 难道用VC++6.0学C++真的是浪费生命?该如何处理

2012-03-04 
FUCK, 难道用VC++6.0学C++真的是浪费生命??刚学C++,看到C++Primer第三版8.4节动态分配对象里的8.4.2auto_p

FUCK, 难道用VC++6.0学C++真的是浪费生命??
刚学C++,看到C++Primer第三版8.4节动态分配对象里的8.4.2auto_ptr。

里面讲到auto_ptr对象定义的第三种情况就是:创建了一个auto_ptr对象,但没有用指针初始化。如果想初始化它,则用reset()操作。。
我根据这写的个简单测试程序如下:

#include   <iostream>
#include   <memory>
using   namespace   std;

int   main()
{
auto_ptr   <int>   p;

if   (   p.get()   !=   0)
*p   =   1024;
else
p.reset(new   int   (80)   );

cout   < <   *p   < <   endl;
                 
                return   0;
}

编译错误提示:说么是reset()不是auto_ptr <int>   模板类的成员。
晕了。。。是我理解不对还是啥的。。

[解决办法]
摘自MSDN 2005


Reference
Constructors
auto_ptr
The constructor for objects of type auto_ptr.

Typedefs
element_type
The type is a synonym for the template parameter Type.

Member Functions
get
The member function returns the stored pointer myptr.

release
The member replaces the stored pointer myptr with a null pointer and returns the previously stored pointer.

reset
The member function evaluates the expression delete myptr, but only if the stored pointer value myptr changes as a result of function call. It then replaces the stored pointer with ptr.


[解决办法]
vc2005express对机器的要求比vc6还低。

热点排行