jeudi 3 novembre 2016

C++primer 5th about func parameter

Its question is" Give the second parameter of make_plural (§ 6.3.2, p. 224) a default argument of 's'. Test your program by printing singular and plural versions of the words success and failure" here is the make_plural.

string make_plural(size_t ctr, const string& word, const string& ending )
{
    return (ctr > 1) ? word + ending : word;
}

Does it mean that change the 'ending', but ending is the third parameter, isn't it? This question worries me a lot! Regards!

Aucun commentaire:

Enregistrer un commentaire