Qt-Autosar-M9.3.1

const member functions shall not return non-const pointers or references to class-data

Required inputs: IR

When a non-const reference to a private data member is handed out to code outside the class, that code could modified the data member in ways that violates the invariants of the class. Data members should be encapsulated: they should be declared as private, and accessor functions should be declared to allow other classes access to the data members.
Example
class C
{
private:
    std::string m_member;

public:
    const std::string& member()
    {
        return m_member;
    }
    void member(const std::string& new_value)
    {
        assert(new_value.size() > 0);
        m_member = new_value;
    }
};
See Also
Rule Miscellaneous-NoPublicDataMembers

Note

For legal reasons, this rule’s description is not part of the public documentation.