腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(3563)
视频
沙龙
1
回答
将
sharet_ptr
<
Derived
>转
换为
shared_ptr
<
Base
>
c++
、
type-conversion
、
shared-ptr
在后面的代码中,我这样做: std::
shared_ptr
<A> Construct(....){ class_field=std::make_shared<B>(...);有没有更好的方法从
shared_ptr
获取
shared_ptr
?
浏览 15
提问于2020-07-07
得票数 2
回答已采纳
2
回答
将
Base
1指针转
换为
boost指针(Boost
shared_ptr
)
c++
、
boost
我有两个基类
Base
1和
Base
2。两者都有1个纯虚函数。另一个称为派生的类通过提供实现来实现上述两个类{ virtual void
Base
1Method()=0;{ virtual void
Base
2Method()=0;{
浏览 0
提问于2014-05-22
得票数 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
<<em
浏览 2
提问于2015-04-18
得票数 1
回答已采纳
2
回答
向下转换时,强制转换不是指针类型
c++
、
pointers
我有一个基类: public: virtual ~
Base
();} public: ...在我的main中,我尝试
将
boost::
shared_ptr
从
base
动态转
换为
derived</em
浏览 0
提问于2020-04-03
得票数 0
1
回答
为什么不将
shared_ptr
隐式转
换为
shared_ptr
到
Base
c++
、
templates
、
inheritance
、
shared-ptr
我不明白为什么在下面的代码中,
shared_ptr
<
Derived
<int>>不被隐式转
换为
shared_ptr
<
Base
<int>> class
Base
{ class
Derived
: public
Base
<
浏览 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);} 我得到了ConvertV
浏览 21
提问于2021-03-24
得票数 0
1
回答
C++中基类和派生类对象的树结构
c++
、
binary-tree
我有两堂课 explicit
Base
(); } explicit
Derived
(std::
shared_ptr
<
Base
> left, std::
shared_ptr
&l
浏览 3
提问于2020-08-20
得票数 1
回答已采纳
2
回答
从Foo<
Derived
>到Foo<
Base
>的转换
c++
、
templates
我正在尝试理解从Foo<
Derived
>到Foo<
Base
>的转换。)
base
->print();{} void takesShare
浏览 0
提问于2017-10-16
得票数 1
回答已采纳
2
回答
指向基类的指针到指针的reinterpret_cast向量
c++
、
reinterpret-cast
、
class-hierarchy
int x; }; int y, z;
Derived
(int xfunction not viable: no known conversion from 'vector<
shared_ptr
<
Derived
>>' to 'const vector<
shared_ptr
>
浏览 3
提问于2016-07-23
得票数 5
1
回答
将
make_shared<
Base
>、继承和转换返回给派生的不按预期工作的方法?
c++
、
c++17
、
shared-ptr
、
make-shared
<
Base
>(new
Derived
(1, 2));{ return result; std::
shared_ptr
<
Base
>
浏览 0
提问于2020-07-19
得票数 1
回答已采纳
1
回答
带有
shared_ptr
的继承和Boost.Python引用参数
python
、
c++
、
boost
、
binding
、
boost-python
{ { {retVal = std::make_shared<
Derived
>(); std::cout << "Creating
Derived
shared_ptr
- " << retVal.get, std::<
浏览 3
提问于2016-03-22
得票数 2
回答已采纳
2
回答
dynamic_pointer_cast从碱基到派生
c++
我对std::dynamic_pointer_cast有意见class
Base
public: virtual ~
Base
() { } {
Derived
(int Data) : m_data(Data) { } std::
shared_ptr
<
Base<
浏览 5
提问于2014-09-12
得票数 1
回答已采纳
1
回答
基类的weak_ptr,而
shared_ptr
是派生类的?
c++
、
templates
、
inheritance
、
c++11
、
shared-ptr
但是,在共享指针所在的管理结构之外,我希望共享指针是更具体的实体(SpecificEntity使用
shared_ptr
<SpecificEntity>作为基类)。
浏览 0
提问于2013-02-21
得票数 8
回答已采纳
1
回答
使用派生类C++返回基类共享指针
c++
、
pointers
、
inheritance
、
shared-ptr
、
abstract-base-class
,在这个接口中还有一个函数:#inclide "
base
.hpp"{
Derived
(instance
浏览 6
提问于2022-07-03
得票数 0
回答已采纳
1
回答
模板基派生的类的
shared_ptr
不能导出模板参数
c++
、
templates
我有一个继承层次结构,基类被模板化,派生类是基类的具体实现:然后,我有一个模板化函数,它接受基类的共享指针:当我试图调用这个方法时,我必
浏览 11
提问于2022-05-13
得票数 0
回答已采纳
3
回答
为什么函数不能正确地转换指针(从基类到派生类)
c++
、
pointers
、
shared-ptr
函数
将
指针转
换为
基类型、指向派生类型的指针的最佳方法是什么?为什么下面的工作不能自动完成?
Derived
: public
Base
{
Derived
() :
Base
() {}; q.push( std::make_shared<
Derived</em
浏览 1
提问于2017-10-25
得票数 0
回答已采纳
1
回答
指向基类派生类的std::unique_ptr的指针
c++
、
pointers
、
polymorphism
、
smart-pointers
、
c++-standard-library
我正在尝试制作一个可以指向任何std::unique_ptr<DerivedClass>的std::unique_ptr<BaseClass>*。 我有如下的类层次结构: [InputHandler] <--inherits from-- [DrawingTool] <--inherits from-- [ToolName] 和以下代码: std::unique_ptr<DrawingTool> *active_tool; active_tool = tool_manager.getCurTool(); // Returns a uniqu
浏览 98
提问于2020-01-28
得票数 0
回答已采纳
1
回答
不能返回包含派生指针的向量
c++
、
c++11
好的,为了说明这个问题,我
将
展示一些(伪)代码。class ContextObject // they implement ObjectInterface} 现在我有了一个TargetSelector类,它只直接使用ObjectInterface。// this is somehow n
浏览 1
提问于2017-02-27
得票数 1
回答已采纳
2
回答
使用智能指针进行继承的pimpl
c++
、
inheritance
、
pimpl-idiom
如果是这样的话,每次我需要使用基指针时,我都必须将其转
换为
派生类型。但是,根据分析结果,静态强制转换
shared_ptr
看起来很昂贵,因为这种强制转换被广泛使用。* ptr); std::
shared_ptr
<BaseImpl> d_Ptr;class BaseImpl
Base
public: ~
Derived<
浏览 4
提问于2016-02-04
得票数 2
回答已采纳
5
回答
是否有可能使指向不同模板类型的指针可转换?
c++
matter what's here reallypublic:};class
Base
{}; 我希望能够做这样的事情(但我认为我做不到):
shared_ptr
<X<
浏览 0
提问于2009-06-17
得票数 4
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
练习题答案:函数指针转换
带你轻松掌握进制转换
PHP 进制转换
base64 格式的数据是如何实现的
Go语言中其他数据与字符串类型的转换
热门
标签
更多标签
云服务器
ICP备案
实时音视频
即时通信 IM
对象存储
活动推荐
运营活动
广告
关闭
领券