gpt4 book ai didi

c++ - boost::smart_ptr 可以用于多态吗?

转载 作者:可可西里 更新时间:2023-11-01 17:39:44 25 4
gpt4 key购买 nike

可以boost::smart_ptr比如scoped_ptr和shared_ptr可以用在多态中吗?

class SomeClass
{
public:
SomeClass()
{
a_ptr.reset(new SubClass);
}
private:
boost::scoped_ptr<SuperClass> a_ptr;
}

最佳答案

我相信答案是肯定的;对 boost 指针进行编码,以便在父类(super class)所在的任何地方都接受派生类。

关于c++ - boost::smart_ptr 可以用于多态吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4763814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com