duplInheritedMember here looks like false positive, because getter is not a duplicate method.
It's not clear why this warning is not generated for setter method for which name hiding is also applied.
If name hiding is bad practice, then there should be appropriate warning.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I understand that setter methods have different signatures, that's why warning is not generated. If cppcheck has no questions for setter method, then current case it's obviously a false positive, because both setter and getter are about name hiding.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Code:
Name hiding is used for both setter and getter.
cppcheck 2.16.0 output:
duplInheritedMember here looks like false positive, because getter is not a duplicate method.
It's not clear why this warning is not generated for setter method for which name hiding is also applied.
If name hiding is bad practice, then there should be appropriate warning.
The two
setter
functions have incompatible argument lists, which suppresses the warning.Yes, I understand that setter methods have different signatures, that's why warning is not generated. If cppcheck has no questions for setter method, then current case it's obviously a false positive, because both setter and getter are about name hiding.
getter()
without args is ambiguous,setter(x)
can be resolved by the argument type.