Under exercise 6.40 of C++ Primer, I am getting -fpermissive error for the following code:
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
string make_plural(size_t ctr, const string &word, const string &ending = "s");
int main()
{
string input;
cout << "Success:" << make_plural(2, "Success", "es") << endl;
cout << "Failure:" << make_plural(2, "Failure") << endl;
return 0;
}
string make_plural(size_t ctr, const string &word, const string &ending = "s")
{
return (ctr > 1) ? word + ending : word;
}
I am used to prototyping the function before the main function first before declaring the function after the main function. However, I am getting fpermissive flag from G++ compiler.
Would like to know why this happened.
Aucun commentaire:
Enregistrer un commentaire