腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
2
回答
为什么
auto_ptr
的接口指定了两个类似复制
构造
函数的
构造
函数
c++
、
stl
、
auto-ptr
我正在浏览这个链接上的
auto_ptr
文档,我
不能
完全理解
为什么
要这样做。在interface部分中,有两个复制
构造
函数的声明
auto_ptr
(
auto_ptr
<X>&) throw (); template <class Y> 这是为了什么。
浏览 0
提问于2010-01-23
得票数 3
回答已采纳
4
回答
为什么
vector.push_back(
auto_ptr
)
不能
编译?
c++
、
stl
、
auto-ptr
我了解到STL可以禁止程序员将
auto_ptr
放入容器中。例如,下面的代码
不能
编译: vector<
auto_ptr
<int> > v;
auto_ptr
有复制
构造
函数,
为什么
这段代码可以编译呢?
浏览 0
提问于2011-09-09
得票数 6
回答已采纳
4
回答
为什么
在std::
auto_ptr
的
构造
函数中
使用
`explict`关键字?
c++
在VS2008编译器中,这是用于从标准指针
构造
std::
auto_ptr
对象的ctor。template<class _Ty>{ explicit
auto_ptr
(_Ty *_Ptr = 0) _THROW0() : _Myptr(_Ptr) {} _Ty *_Myptr;
使用
上面的explicit关键字有什么特殊的原因吗?换句话说,
为什么
我
不能
用初始化<e
浏览 0
提问于2011-11-17
得票数 4
回答已采纳
4
回答
为什么
auto_ptr
构造
不能
使用
=语法
c++
、
gcc
、
stl
、
auto-ptr
我遇到了一个编译器错误,这对我来说没有多大意义:using namespace std; 错误:请求从'Table*‘转换为非标量类型'std::
auto_ptr
< Table>’
auto_ptr
<Table> table(db->query("select
浏览 0
提问于2009-04-16
得票数 9
回答已采纳
3
回答
为什么
不允许
使用
赋值语法进行
auto_ptr
初始化
c++
、
initialization
、
auto-ptr
我在读这本书std::
auto_ptr
<ClassA> ptr2 = new ClassA; //error 我不明白
为什么
不允许通过不允许
使用
赋值语法初始化,他们试图避免什么样的陷阱。
浏览 10
提问于2016-07-23
得票数 3
回答已采纳
2
回答
接受
auto_ptr
的
构造
函数
c++
、
initialization
、
auto-ptr
我想编写一个带有
构造
函数的C++类,该
构造
函数以
auto_ptr
作为其参数,这样我就可以将类实例从
auto_ptr
初始化到另一个实例:{但是,如果我
使用
语法A y (create());来创建我的对象,它就能工作。我想知道
为什么
会发生这种情况,如果有什么我可以做的事情
浏览 3
提问于2013-10-28
得票数 0
回答已采纳
1
回答
C++隐式转换unique_ptr /
auto_ptr
到基类型不工作?
c++
、
templates
、
polymorphism
{} std::
auto_ptr
< B > b( new B() );}由于
auto_ptr
(参见)定义的转换
构造
函数,隐式转换。但是,我得到了错误: 错误:从“std::
auto_ptr
”到“std::<e
浏览 2
提问于2021-06-01
得票数 0
4
回答
为什么
C++
auto_ptr
有两个复制
构造
函数和两个赋值操作符,但却有一个默认
构造
函数?
c++
、
stl
为什么
它需要两个表单?谢谢
auto_ptr
(
auto_ptr
<Y>& rhs) throw() template<c
浏览 0
提问于2010-11-30
得票数 7
2
回答
当
auto_ptr
是一个函数的参数时,如何调用它!
c++
void fun() std::cout<< x<<" "<<y<<" "<<std::endl;}; void show(std::
auto_ptr
浏览 0
提问于2011-06-17
得票数 2
回答已采纳
3
回答
为什么
unique_ptr可以工作,但
auto_ptr
没有
使用
STL
c++
、
stl
、
copy-constructor
、
unique-ptr
、
auto-ptr
在这些问题上,我提到了很多StackOverflow链接,其中
auto_ptr
不能
很好地
使用
STL的原因是std::
auto_ptr
<>不满足可复制、可
构造
和可分配的要求(因为
auto_ptr
有一个假的副本
构造
函数
浏览 1
提问于2019-11-09
得票数 1
回答已采纳
3
回答
如何实现std::
auto_ptr
的复制
构造
函数?
c++
、
smart-pointers
、
copy-constructor
、
auto-ptr
void Swap(AutoArray&);)这会失败,因为复制
构造
函数接受非const引用作为参数...但我不明白如何修改复制
构造
函数以获取const引用,因为赋值中
使用
的源AutoArray已被修改(因此不会是const)。当然,你
不能
修改东西来
使用
pass by value,因为它是复制
构造
函数,那将是一个无限循环!如果我
使用
的是
auto_ptr
,这将是有效的: std:
浏览 2
提问于2010-12-23
得票数 6
回答已采纳
3
回答
C++ std::
auto_ptr
复制
构造
函数
c++
、
auto-ptr
std::
auto_ptr
缺少常量复制
构造
函数,因此我
不能
在集合中直接
使用
它。例如,有没有办法在不
使用
boost指针集合模板的情况下拥有std::
auto_ptr
的向量?
浏览 0
提问于2010-10-20
得票数 3
回答已采纳
3
回答
为什么
智能指针模板需要禁用在
构造
函数中引发的异常
c++
、
templates
、
smart-pointers
本书举例说明了如何实现
auto_ptr
类,如下所示,public:...}; 在
构造
函数末尾抛出()意味着此
构造
函数不会抛出异常。我知道这是不可取的,但我不知道
为什么
它需要禁用其异常抛出。
浏览 4
提问于2016-02-10
得票数 1
2
回答
auto_ptr_ref实现问题
c++
、
stl
关于
auto_ptr
<>和auto_ptr_ref<>的内部实现,我看过不同的来源。我有一个问题,我不知道
为什么
。……当从函数返回'
auto_ptr
‘时,编译器发现没有合适的ctor来复制返回的对象。但是有转换为'auto_ptr_ref‘和ctor,
使用
'auto_ptr_ref’来
构造
'
auto_ptr
‘。因此,编译器创建一个'auto_ptr_ref‘,它基本上只保存对原始'
auto_ptr
浏览 1
提问于2013-07-23
得票数 1
2
回答
例如vectors<>,
为什么
unique_ptr可以与标准容器一起
使用
?
c++
、
vector
、
unique-ptr
、
auto-ptr
我知道
auto_ptr
不能
与向量一起
使用
,因为
auto_ptr
不满足复制可
构造
的要求。由于要复制的
auto_ptr
已被修改,因此复制不会产生两个完全相同的副本,从而违反了复制可
构造
习惯用法。那么,如何在向量中而不是auto_ptrs中
使用
uinque_ptr呢?vector <
auto_ptr
浏览 3
提问于2015-02-24
得票数 1
1
回答
在smart_ptr
构造
函数中,
为什么
要传递值而不传递const?
c++
、
constructor
、
parameter-passing
、
smart-pointers
、
auto-ptr
在它中,有一个
auto_ptr
的实现,
构造
函数编写如下:class
auto_ptr
{ T* pointee;
auto_ptr
<T>(T* p) : pointee(p) {}我的问题是:
为什么
构造
函数中的指针不被const引用传递?p在
构造
函数中没有更改,所以const看起来很好,通过引用传递
浏览 5
提问于2022-05-29
得票数 0
1
回答
为什么
auto_ptr
中有模板复制
构造
函数和重写操作符函数?
c++
、
auto-ptr
为什么
auto_ptr
中有模板复制
构造
函数和重写操作符函数? template <class Y> struct auto_ptr_ref {};
auto_ptr
(auto_ptr&) throw();
浏览 4
提问于2016-06-13
得票数 4
回答已采纳
1
回答
如何用rvalue初始化std::
auto_ptr
?
c++
、
copy-constructor
、
c++03
、
c++98
、
auto-ptr
std::string("yyyyyyyyyyyyy");{} { if (x) {
浏览 3
提问于2016-06-17
得票数 3
回答已采纳
1
回答
构造
函数中指针的默认值是什么意思?
c++
、
pointers
、
constructor
、
default-value
我试着理解这段代码(取自):{public: ~
auto_ptr
() {delete ptr;} T* operator->() {return ptr;}
浏览 0
提问于2013-04-05
得票数 5
回答已采纳
7
回答
C++:
auto_ptr
+转发声明?
c++
、
memory-management
、
pointers
、
shared-ptr
、
auto-ptr
Inner; { Cont();private:};class Inner; { Cont();private: std::
auto_ptr
<Inner> m_inner;
浏览 10
提问于2009-12-23
得票数 12
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
对象存储
即时通信 IM
云直播
活动推荐
运营活动
广告
关闭
领券