草庐IT

inheritence

全部标签

c++、cscope、ctags 和 vim : Finding classes that inherit from this one

在具有几层的相当大的代码库中,有没有办法在vim或命令行中找到从基类派生的所有类?grep是一个选项,但可能会很慢,因为grep没有索引。 最佳答案 cscope和ctags都不允许我们直接处理继承,但是相对解决这个限制是很容易的,因为派生类也被索引了。控制范围在cscope中,寻找“C符号”Foobar通常会列出原始类和继承自它的类。由于搜索是针对数据库完成的,因此速度快如闪电。或者,您可以使用cscope的egrep搜索功能和类似:.*Foobar的模式来列出仅继承自Foobar的类。因此,即使我们没有专门的“查找继承自此类的类

C++ : union of two types without virtual base class inheritance

是否可以在不手动创建交集类型的情况下创建两种类型的并集?问题是在我的上下文中交集类是完全没有意义的,所以创建它会使代码用户感到困惑。我的实际案例:我正在描述一个数字硬件模拟器,它是许多模块的分层树状结构:classport;classmodule0{porta,b,c;}classmodule1{portc,d,e;}我需要创建这两种类型的union:classtop_level_module{porta,b,c,d,e;}我想应该有一些技术来创建union类型(这是我要问的问题):classtop_level_module:union_type{//porta,b,c,d,e;}但是

c++ - 如何正确链接 boost::mpl::inherit_linearly 和 boost::mpl::inherit 以便解析占位符?

假设我有这些类型:templateclassStorage>structAbstractFactoryUnit{virtual~AbstractFactoryUnit(){}virtualtypenameStorage::StoredTypedoCreate(Storage)=0;};和templateclassProductStorage,templateclass>classUnit=AbstractFactoryUnit>structAbstractFactory:boost::mpl::inherit_linearly>>::type{typedefTypeSequencePr

c++ - "a struct has public inheritance by default"

“默认情况下结构具有公共(public)继承”这句话的真正含义是什么?为什么下面的代码错误只是因为我在从c派生类d时省略了关键字'public'??structc{protected:inti;public:c(intii=0):i(ii){}virtualc*fun();};c*c::fun(){coutfun();} 最佳答案 意思是structc;structd:c相当于structd:publicc您的代码是一个类,扩展了一个结构:structc;classd:c;相当于classd:privatec;因为class默认有私

ios - fatal error : unexpectedly found nil while unwrapping an Optional value in inheriting class

我创建了一个CustomTopTabbarController来自定义标签栏。@objcMemberspublicclassCustomTopTabbarController:UITabBarController{@IBOutletweakvarcustomBar:UITabBar!publicoverridefuncviewDidLoad(){super.viewDidLoad()customBar.frame=CGRect(x:0,y:0,width:customBar.frame.size.width,height:customBar.frame.size.height)}pub

ios - Realm +地幔: how to avoid multiple inheritance duplication when integrating both frameworks?

我有一个简单的场景,我想用Mantle从Json解析一个用户模型并将其保存到Realm数据库:为了使用Mantle库,模型接口(interface)必须像这样扩展MTLModel类:@interfaceUser:MTLModel@property(nonatomic,copy)NSString*name;@property(nonatomic,copy)NSString*email;@end为了在Realm中保留该模型,我必须声明从RLMObject扩展的第二个接口(interface):@interfaceRLMUser:RLMObject@property(nonatomic,co

PHP 反射 : How to know if a method/property/constant is inherited from trait?

我想从列表中排除特征的所有继承方法未在类中被覆盖那么如何知道一个类成员是否继承自trait?是的,我可以这样检查:if($trait->hasMethod($methodName)||$ref->getTraitAliases()[$methodName]!==null){//}但是如果类中的trait方法被重写了怎么办?怎么知道呢?一种方法是检查方法体是否相似,如果是,我可能会排除它,但是否有更好的方法来实现这一点? 最佳答案 一个更简单的方法是ReflectionMethod::getFileName()。这将返回特征的文件名,

php - Doctrine 2 : Arbitrary join and single table inheritance

注意:这是一个ORM限制reportedontheproject'sissuetracker我在使用Doctrine2.3中引入的任意连接语法在作为层次结构根的实体类上构建DQL查询时遇到问题。给定这些类:A-noinheritanceB1-abstract,rootofahierarchy,discriminatorcolumnisnamed'type'我像这样设置一个查询构建器:$qb->select('a.idASidA,b.idASidB')->from('\Entity\A','a')->leftJoin('\Entity\B1','b',\Doctrine\ORM\Quer

flutter开发警告This class (or a class that this class inherits from) is marked as ‘@immutable‘, but one

文章目录问题描述问题代码问题原因如何解决修改后的源码问题描述Thisclass(oraclassthatthisclassinheritsfrom)ismarkedas‘@immutable’,butoneormoreofitsinstancefieldsaren’tfinal:SerialsTimer.tasks问题代码classSerialsTimerextendsStatefulWidget{lateQueueTask>tasks;//使用Queue来管理任务SerialsTimer({Key?key,requiredthis.tasks,}):super(key:key);@overr

c++ - 为什么我们不能在 COM 中使用 "virtual inheritance"?

我读过一些模糊的声明virtualinheritance没有提供COM需要的内存结构,所以我们只好使用普通的继承。发明虚拟继承是为了解决菱形继承(钻石问题)。有人可以向我展示这两种继承方法之间内存结构细节差异的图示吗?以及虚拟继承不适合COM的关键原因。最好有照片。非常感谢。 最佳答案 首先,在COM中总是使用虚拟继承的行为。QueryInterface无法返回不同的值,例如IUnknown基指针取决于用于获取它的派生类。但是您是对的,这与C++中的虚拟继承机制不同。C++不使用QueryInterface函数进行向上转换,因此它需