multiple-inheritance

    0热度

    2回答

    我试图使用多继承。 人是我的基础班。 学生和Angestellter继承受保护的属性。 WissenschaftlicheHilfskraft也应该继承这些属性(来自Person,Student,Angestellter),但我无法在最后一个派生类中调用方法get_name()。为什么? #include <iostream> using namespace std; class Pers

    0热度

    1回答

    我想创建两个A类和B类,其中B是A的一个轻微但显着的变体,然后创建第三个类C,它可以继承A或B并添加功能给他们。问题是,我如何告诉C根据我的偏好继承A或B? 为了让事情更加清楚,假设我有这样的代码: class A: def __init__(self, x, y): self.x = x self.y = y def first(self):

    1热度

    2回答

    mother对象如何在调用类型为son时能够调用father的函数? 这里的father对象没有创建,那么如何来调用drive()函数。对于新手的问题抱歉。 #include <iostream> using namespace std; #include <iostream> using namespace std; class father { public:

    1热度

    1回答

    下面的代码: class A1 { public: int x; }; class A2 { private: int x() { return 67; } }; class M : public A1, public A2 {}; int main() { M m; m.x; } 编译错误: error C2385: ambiguo

    0热度

    1回答

    正如How does Python's super() work with multiple inheritance?中所解释的,super也可用于多继承,因为它将在父代中查找属性。但是什么属性?子类已经包含一个super(如果你看下面的代码)。我如何指定我想要的属性?我想要Error的构造函数。 class Error(object): def __init__(self, value

    3热度

    2回答

    让我告诉你我遇到的问题。我正在设计一组控制数字设备的类。该设备可以在两种操作模式下工作。在第一种模式下,它可以执行一组特定的操作,而在第二种模式下,它可以执行另一组操作(两者之间可能有一些共同的操作)。我还可以在运行中更改设备的模式,以便在必要时可以在两种模式之间切换。独立于该模式,器件使用相同的一组寄存器。 我在考虑用每个模式的一个基类来解决这个问题,所以当我需要第二组操作时需要模式2的第一组操

    4热度

    7回答

    代码打印所有的构造函数。我读到构造函数在我们从另一个类派生一个类时没有被继承。那么为什么创造c从b和a class A { public: A() { cout << "A's constructor called" << endl; } }; class B { public: B() { cout << "B's constructor called" <<

    0热度

    1回答

    我的问题是this question有点相关,以及相应的solution已经证明是有益的和有帮助的,但是有来自这个问题一点题外话,我想进一步解释: 我已经使用active_record-acts_as宝石在devise宝石创建具有多个注册的形式和单一的签到表,这样我有一个名为客户和其他客户端类型,例如公司和个人充当一个设计模型的模型客户设计模型,以及所有这些MTI制作都基于o呐布局从applica

    2热度

    2回答

    我们可以称这个代码为多继承吗? interface Interface { public int alpha = 0; public int calculA(int a, int b); public int calculB(int a, int b); } interface InterfaceA extends Interface { publ

    1热度

    2回答

    在OpenAPI中,使用allof可以实现继承。例如,在this example: "definitions": { "Pet": { "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" # <--- here }, [...] ]