I see the following code snippet from a C ++ tutorial, but I think it has a problem with access.
Class A has a private data element valand a public member function const A & topval(const A & b) constthat returns a reference to an object that has a larger val. I think the use b.valbelow is wrong, as it accesses personal data from outside, do I understand correctly?
const A & A::topval(const A & b) const
{
if (**b.val** > val)
return b;
else
return *this;
}
source
share