Autosar 8-5-1-初始化顺序
规则(
在初始化列表中,初始化顺序应如下:
(1)继承图的深度和从左到右的虚拟基类,
(2)(2)从左到右的直接基类直接基类继承列表的顺序,
(3)在班级定义中声明的订单的非静态数据成员。
myClass.h
class MyClass {
public:
MyStruct m_s;
MyTypedef m_t;
explicit Participant(MyStruct &s, MyTypedef t);
private:
AnotherClass m_r;
}
myclass.cpp
MyClass::MyClass(MyStruct &s, MyTypedef t)
: m_s(s), m_t(t), m_r(this) {} // violates A8-5-1 (m_r is marked as violation)
该订单实际上与标题文件中的订单匹配。我不明白为什么违反该规则。我想念什么吗?
Rule (8-5-1):
In an initialization list, the order of initialization shall be following:
(1) virtual base classes in depth and left to right order of the inheritance graph,
(2) direct base classes in left to right order of inheritance list,
(3) non-static data members in the order they were declared in the class definition.
MyClass.h
class MyClass {
public:
MyStruct m_s;
MyTypedef m_t;
explicit Participant(MyStruct &s, MyTypedef t);
private:
AnotherClass m_r;
}
MyClass.cpp
MyClass::MyClass(MyStruct &s, MyTypedef t)
: m_s(s), m_t(t), m_r(this) {} // violates A8-5-1 (m_r is marked as violation)
The order actually matches the order from the header file. I don't understand why this rule is violated. Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论