腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(7463)
视频
沙龙
1
回答
为什么不将
shared_ptr
隐式转
换为
shared_ptr
到
Base
c++
、
templates
、
inheritance
、
shared-ptr
我不明白为什么在下面的代码中,
shared_ptr
<
Derived
<int>>不被隐式转
换为
shared_ptr
<
Base
<int>> class
Base
{ class
Derived
: publi
浏览 1
提问于2020-10-21
得票数 0
回答已采纳
2
回答
如何
将
shared_ptr
<
Derived
>的向量转
换为
shared_ptr
<
Base
>?
c++
、
vector
、
shared-ptr
我想把
shared_ptr
<
Derived
>的向量转换成
shared_ptr
<
Base
>的向量{class
Derived
: public
Base
}; ConvertVecBasePtr(d); return
浏览 21
提问于2021-03-24
得票数 0
1
回答
将
make_shared<
Base
>、继承和转换返回给派生的不按预期工作的方法?
c++
、
c++17
、
shared-ptr
、
make-shared
<
Base
>(new
Derived
(1, 2));{ return result;
std
::<em
浏览 0
提问于2020-07-19
得票数 1
回答已采纳
1
回答
模板基派生的类的
shared_ptr
不能导出模板参数
c++
、
templates
{};template <typename
T
> void DoSomething(const
std
::
shared_ptr
<
Base
<
T
>> &ptr);
std
::
shared_ptr
<
Derived
> d =
std
::make_shared<
Derive
浏览 11
提问于2022-05-13
得票数 0
回答已采纳
3
回答
无法使用
std
::未来存储多态对象
c++
、
multithreading
、
concurrency
、
future
struct
Derived
: public
Base
{
std
::cout << "I am
derived
" <<
std
::endl;};
std
::future<
std
::
shared_ptr
<
Base
>> f =
std
浏览 5
提问于2021-09-20
得票数 2
回答已采纳
1
回答
当通过引用传递时,
std
::
shared_ptr
如何跨类层次结构进行转换?
c++
、
c++11
、
type-conversion
、
shared-ptr
、
implicit-conversion
查看20.8.2.2类模板
shared_ptr
util.smartptr.shared,我意识到
std
::
shared_ptr
具有模板复制构造函数和赋值操作符,允许
将
shared_ptr
<
Derived
>转
换为
shared_ptr
<
Base
>当且仅当
Derived
*可转
换为
Base
*。但是,我似乎也可以
将
shared_ptr</e
浏览 2
提问于2015-04-18
得票数 1
回答已采纳
2
回答
std
::
shared_ptr
、继承和模板参数演绎中的问题
c++
、
templates
、
inheritance
、
c++11
、
smart-pointers
正如您在下面的示例代码中所看到的,我正在
将
一个
shared_ptr
<
Derived
>传递给一个模板化的非会员函数,该函数应该执行模板参数推导。( 2010)class
Base
{}; void
浏览 5
提问于2013-06-03
得票数 13
回答已采纳
1
回答
带有
shared_ptr
的继承和Boost.Python引用参数
python
、
c++
、
boost
、
binding
、
boost-python
{ { {retVal =
std
::make_shared<
Derived
>();
std
::cout << "Creating
Derived
shared_ptr
- "
浏览 3
提问于2016-03-22
得票数 2
回答已采纳
2
回答
带派生类的C++共享指针
c++
、
c++11
、
pointers
、
shared-ptr
下面是代码: public:
Base
(); virtual Ptr getShared() = 0; public: // d
浏览 5
提问于2018-01-05
得票数 0
回答已采纳
1
回答
C++中基类和派生类对象的树结构
c++
、
binary-tree
我有两堂课 explicit
Base
(); } explicit
Derived
(
std
::
shared_ptr
<
Base
> left,
std<
浏览 3
提问于2020-08-20
得票数 1
回答已采纳
2
回答
指向基类的指针到指针的reinterpret_cast向量
c++
、
reinterpret-cast
、
class-hierarchy
) :
Base
(x), y(x + 1), z(x + 2) {} void update(const
std
::vector<
std
::
shared_ptr
<const
Base
>>& elements<
Derived
>>' to 'const vector<
shared_ptr
<const
Base
>>' for 1st argumen
浏览 3
提问于2016-07-23
得票数 5
3
回答
函数模板
将
shared_ptr
向量填充到基派生对象
c++
、
templates
、
inheritance
、
shared-ptr
、
stdvector
Derived
(double z0) , z{ z0 } double z;
std
::vector<
std
::
shared_ptr
<
Base
>> Mak
浏览 0
提问于2019-08-13
得票数 2
回答已采纳
3
回答
为什么函数不能正确地转换指针(从基类到派生类)
c++
、
pointers
、
shared-ptr
函数
将
指针转
换为
基类型、指向派生类型的指针的最佳方法是什么?为什么下面的工作不能自动完成?
Derived
: public
Base
{
Derived
() :
Base
() {}; void foo(const
std
::
shared_ptr
<
Derived
>::queue<
std
::
shared_ptr
<
Base
>&g
浏览 1
提问于2017-10-25
得票数 0
回答已采纳
1
回答
基类的weak_ptr,而
shared_ptr
是派生类的?
c++
、
templates
、
inheritance
、
c++11
、
shared-ptr
但是,在共享指针所在的管理结构之外,我希望共享指针是更具体的实体(SpecificEntity使用
shared_ptr
<SpecificEntity>作为基类)。
浏览 0
提问于2013-02-21
得票数 8
回答已采纳
3
回答
std
::
shared_ptr
丢失常量的实例化类型
c++
、
c++11
给定以下程序:class SharedPtr : public
std
::
shared_ptr
<
T
> typedef
std
::
shared_ptr
<
T
> Impl; SharedPtr( Impl const&a
浏览 2
提问于2013-05-23
得票数 3
回答已采纳
1
回答
std
::
shared_ptr
在C++中的克隆模式
c++11
、
overriding
、
clone
、
smart-pointers
、
virtual-functions
std
::cout << "
Base
::Clone\n"; }struct
Derived
: public
Base
{ virtual
std
::
shared_ptr
<
Derived
> Clone()
浏览 5
提问于2017-04-24
得票数 8
回答已采纳
2
回答
std
::make_shared与
std
::initializer_list
c++
、
c++11
、
std
#include <iostream>{
Base
() {}{
Derived
() {}
Derived
(
std
::initializer_list<
std
::pair<int,
std
::
shared_ptr<
浏览 0
提问于2014-06-15
得票数 21
回答已采纳
2
回答
从Foo<
Derived
>到Foo<
Base
>的转换
c++
、
templates
:}; void takesConstSharedPtr(const
std
::
shared_ptr
<
Base
>&
base
)
base
->print(); void takesConstSharedPtrConst(const
std
::
shared_ptr
浏览 0
提问于2017-10-16
得票数 1
回答已采纳
2
回答
Cython中的继承和
std
::
shared_ptr
python
、
c++
、
inheritance
、
cython
、
shared-ptr
假设我在C++中有以下简单的file.h继承示例class
Derived
: public
Base
{};
Derived
* foo = new
Derived
();
std</
浏览 11
提问于2021-05-20
得票数 7
回答已采纳
4
回答
无法从“const
shared_ptr
<
base
_class>”转
换为
“
shared_ptr
<
derived
_class>”
c++
、
class
、
c++11
、
smart-pointers
、
stdvector
我声明了以下vector我有以下变量:我想做以下几件事:我得到以下错误: Cannot convert from 'const
shared_ptr
<
base
_class>'to '
浏览 0
提问于2018-06-23
得票数 0
回答已采纳
点击加载更多
相关
资讯
这几个C+的坑,一旦踩中了,加班是肯定避免不了了!
实现线程安全队列——细粒度锁实现
C+11 shared_ptr智能指针(超级详细)
谈 C++17 里的 Memento 模式
Boost.Python(一)
热门
标签
更多标签
云服务器
对象存储
ICP备案
云点播
语音识别
活动推荐
运营活动
广告
关闭
领券