I’m using SonarLint 5.3.0.36775 in JetBrains’ CLion and it keeps telling me to avoid shadowing inherited function sound() or to declare it virtual. Problem is that it’s already virtual, pure virtual to be exact, so I believe this is a false positive.
public:
std::string who() const;
virtual std::string sound() const = 0;
protected:
Animal(std::string name, int weight) :
m_name{name}, m_weight{weight} {}
private:
std::string m_name;
int m_weight;
};
class Sheep : public Animal{
public:
using Animal::Animal;
std::string sound() const override;
};
The problem is in finding the STL headers with Visual Studio Compilers. So you might face some false positives/negatives because of that. The fix should be available with SonarLint next release.