Autosar C++规则3-1-5-类定义中的功能定义
我的代码违反了以下AUTOSAR规则:
规则3-1-5:
仅在
时才将函数定义放置在类定义中。
- 该函数旨在分配
- 它是成员函数模板
- 它是类模板的成员函数。
ah:
class A {
public:
void stop();
private:
bool x = false;
};
a.cpp:
void A::stop() { // violates AUTOSAR 3-1-5
x = false;
}
我尝试使用关键字inline
来定义该函数,但这并不能解决问题。
违规仅发生仅由仅由一条线组成的函数。如果在不存在类的标题文件中定义函数(例如,在结构中),也会发生此问题。
有人知道如何解决吗?
My code violates the following AUTOSAR rule:
Rule 3-1-5:
A function definition shall only be placed in a class definition if
- the function is intended to be inlined
- it is a member function template
- it is a member function of a class template.
A.h:
class A {
public:
void stop();
private:
bool x = false;
};
A.cpp:
void A::stop() { // violates AUTOSAR 3-1-5
x = false;
}
I tried defining the function with the keyword inline
, but that didn't solve the problem.
The violation occurs only with functions that consist of only one line. This problem also occurs if the function is defined in a header file where no class exists (e.g. in a struct).
Does anyone have an idea how I can solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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