override c++ ’ marked ‘override’, but does not override fix
this bug comes from this:
if :
head1.hh
class head1 {
virtual int initialize(nlohmann::json& json_config) = 0;
}
head2.hh
class head2:public head1
{
virtual int initialize(nlohmann::json& json_config) override;
}
head2_imple.cpp
int head2::initialize(nlohmann::json& json_config)
{
//...
}
keep the para into initialize() (in bracket ) the same,or it will yell "override c++ ’ marked ‘override’, but does not override"
本文探讨了C++中使用'override'关键字时遇到的一个常见错误:即使已明确声明了覆写,编译器仍报错提示未真正覆写基类函数。文章通过具体的代码示例解释了错误产生的原因,并提供了确保正确覆写的解决方案。
6550

被折叠的 条评论
为什么被折叠?



