草庐IT

Derived_A

全部标签

python - Cython/Python/C++ - 继承 : Passing Derived Class as Argument to Function expecting base class

我正在使用Cython包装一组C++类,允许它们使用Python接口(interface)。示例代码如下:基类.h:#ifndef__BaseClass__#define__BaseClass__#include#include#includeusingnamespacestd;classBaseClass{public:BaseClass(){};virtual~BaseClass(){};virtualvoidSetName(stringname){printf("inbasesetname\n");}virtualfloatEvaluate(floattime){printf("

ios - ld : warning: directory not found for option -- deleting derived data and cleaning project don't work

这个问题在这里已经有了答案:‘ld:warning:directorynotfoundforoption’(32个答案)关闭9年前。我将我在Xcode中处理的应用程序的整个文件夹从我计算机上的一个位置移动到另一个位置,并收到警告ld:warning:directorynotfoundforoption后跟一个长长的路径。我遵循了AppleMach-OLinkererrorsandIdon'tknowwhattodo上接受的答案但仍然收到相同的警告。编辑:如果相关,这是我收到的消息:Ld/Users/joel/Library/Developer/Xcode/DerivedData/Gay

c# - 为什么不能将 List<Derived> 分配给 List<Base>?

我定义了以下类:publicabstractclassAbstractPackageCall{...}我还定义了这个类的一个子类:classPackageCall:AbstractPackageCall{...}AbstractPackageCall还有其他几个子类现在我想进行以下调用:Listcalls=package.getCalls();但我总是得到这个异常(exception):Error13Cannotimplicitlyconverttype'System.Collections.Generic.List'to'System.Collections.Generic.List

sql - MySQL 错误 1248 (42000) : Every derived table must have its own alias

我这辈子都想不通为什么会出错SELECT*FROMSELECTc.city_id,p.prop_ynow_id,p.propertyid,p.prop_add_value,p.name,picture,ifnull(p.address,'')as`location`,ifnull(city,'')as`city`,ifnull(ShortCut,'')as`state`,ifnull(p.zip,'')as`zip`,min(if(pr.minrent=0,99999999,pr.minrent))asminrent,max(pr.maxrent)asmaxrent,''asservi

android - fragment Activity : Cannot cast from Fragment to derived class

我正在尝试在FragmentActivity中使用Fragment,如下所示:TutViewerFragmentviewer=(TutViewerFragment)getSupportFragmentManager().findFragmentById(R.id.tutview_fragment);我的TutViewerFragment扩展了Fragment。但是我收到一个错误:CannotcastfromFragmenttoTutViewerFragment.我真的不明白为什么会这样。为什么不能转换? 最佳答案 您扩展了错误的Fr

c++ - 在基本 ctor-initialiser 中将其强制转换为 `Derived*` 是否合法?

给出以下CRTP示例:templateintfoo(T*const){return0;}templatestructBase{Base():bar(foo(static_cast(this)){};intbar;};structDerived1:Base{};是this的转换至Derived*这里有效吗?我似乎记得可能不是,但现在找不到具体的证据。this的“自然”类型在这个阶段是Base*const,并且在某些情况下,甚至可以静态转换this初始化期间的指针不正常,例如在基础构造完成之前向上转换(12.7/3)。@DeadMG说:there'sanexplicitexceptioni

c++ - 在标准中,什么是 "derived-declarator-type"?

在C++(C++11)标准的不同地方,声明是根据derived-declarator-type-list来描述的。我正在研究右值引用,在这种情况下使用这个术语是至关重要的(第8.3.2节):InadeclarationTDwhereDhaseitheroftheforms    &attribute-specifier-seqoptD1    &&attribute-specifier-seqoptD1andthetypeoftheidentifierinthedeclarationTD1is“derived-declarator-type-listT,”thenthetypeofth

c++ - static_cast<Derived *>(Base pointer) 是否应该给出编译时错误?

static_cast(Basepointer)是否应该给出编译时错误?classA{public:A(){}};classB:publicA{public:B(){}};intmain(){A*a=newA();B*b=static_cast(a);//CompileError?} 最佳答案 它不会给出编译时错误,因为Base-Derived关系可以在运行时存在,具体取决于被强制转换的指针的地址。static_cast总是成功,但如果你不转换为正确的类型,则会引发undefined-behavior。dynamic_cast可能会

c++ - 为什么不允许从 VirtualBase::* 转换为 Derived::*?

昨天,我和我的同事不确定为什么语言禁止这种转换structA{intx;};structB:virtualA{};intA::*p=&A::x;intB::*pb=p;连类型转换都没有帮助。如果基成员指针是虚拟基类,为什么标准不支持将基成员指​​针转换为派生成员指针?相关C++标准引用:Aprvalueoftype“pointertomemberofBoftypecvT”,whereBisaclasstype,canbeconvertedtoaprvalueoftype“pointertomemberofDoftypecvT”,whereDisaderivedclass(Clause1

c++ - 无法将 "derived"转换为其私有(private)基类 "base"

这个问题在这里已经有了答案:CanIcastaderivedclasstoaprivatebaseclass,usingC-stylecast?(3个回答)关闭7年前。我在尝试创建一个继承自定义纯虚函数的类的类的对象时遇到错误。我不确定出了什么问题。我知道我需要重写派生类中的纯虚函数,但它不起作用。我只想重写ProduceItem类中的函数,而不是Celery类,因为我希望Celery类从ProduceItem继承重写的方法。在主要:GroceryItem*cel=newCelery(1.5);//Cannotcast'Celery'toitsprivatebaseclassGroce