Static code analysis identifies the constructor parameters begin and end as names that hide the corresponding member functions (read functions) according to Misra Rule 2-10-2 (Identifiers declared in an inner scope shall not hide an identifier declared in an outer scope).
Is this correct?
template <typename T>
class TLineSegment
{
public:
TLineSegment(const point_type& begin, const point_type& end)
: m_begin(begin)
, m_end(end)
{
}
const point_type& begin() const
{
return m_begin;
}
const point_type& end() const
{
return m_end;
}
private:
point_type m_begin;
point_type m_end;
}
The compiler looks first at names, and then figures out what to do with them. So
beginis the name of the function argument. The compiler won’t look past that to see if there’s some other definition that can be used in the function call.