Class functions

Hello. I'm confused by this:
1
2
3
const Stock & topval(const Stock & s) const;
...
top = stock1.topval(stock2);


And this:
1
2
3
4
5
6
7
const Stock & Stock::topval(const Stock & s) const
{
if (s.total_val > total_val)
    return s;
else
    return *this
}


The book says that I can substitute the 2nd workings with the 1st, but I don't see how that can be replaced. The function is to compare and return the object of higher value between 2 objects. Is it that the 1st is incomplete?

Thanks!
The first group of lines contains a function declaration; on line three an example of how to call the topval member function of stock1.

The second group of lines contains a function definition.

So the first block shows an example, the second block shows the actual function.
Topic archived. No new replies allowed.