English 中文(简体)
这项工作吗? C++ 多重遗产和建筑链条
原标题:Does this work? C++ multiple inheritance and constructor chaining

考虑从Foo和Baz继承一个等级,即:

class Waldo : public Foo, public Baz {
  ...
};

当我创立一个瓦尔多的新案例时:

   Waldo *w = new Waldo;

Foo和Baz建筑商被叫来吗? 如果他们没有被缺席要求,那么在瓦多建筑商的《宣言》/定义中,他们是否很容易被叫作?

(It looks like I may be trying to do constructor chaining, and C++ allegedly doesn t do that. I m not sure.)

我试图做的是“通知”各种类别申报,其中说明引起附加说明的类别(除别的以外)与说明类别保持的清单挂钩。 比如,请允许我从所有具有Baz-nature的物体的名单上删除,对它们适用某种操作,而不必担心我是否记得在有Baz-nature的物体清单中添加了例子,因为施工者是自动这样做的。

最佳回答

某类所有成员的造物按在班级申报的顺序排列。

衍生产品的违约构造者将基类的构造者称作违约。 如果他们需要论据,就必须明确援引,这是错误......

 class Employee {
 private:
     //
 public:
    Employee();
    //...
 };



 class Manager: public Employee {
 private:
     short level;
 public:
     Manager(): Employee(), level() {}    // This is the default constructor, it calls Employee(). 
     // The definition is equivalent to default constructor of Manager..
     //...
  };
问题回答

是的,他们叫了。 放弃权利。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签