Each member function, including constructors and destructors, has a this pointer. The special prop-erty of the this pointer is that it points to the invoking object. If a method needs to refer to theinvoking object as a whole, it can use the expression *this. Using the const qualifier after the func-tion argument parentheses qualifies this as being const; in that case, you can’t use this to changethe object’s value.
const Stock& Stock::topval(const Stock &s) const
{
using std::cout;
using std::endl;
cout<<"s.total_val="<<s.total_val<<endl;
cout<<" total_val="<<total_val<<endl;
if(s.total_val > total_val)
return s;
else
return *this;
}