File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 1
- // ! @Alan
1
+ // ! @Yue Wang
2
2
// !
3
3
// ! Exercise 6.42:
4
4
// ! Give the second parameter of make_plural (§ 6.3.2, p. 224) a default
5
5
// ! argument of 's'. Test your program by printing singular and plural
6
6
// ! versions of the words success and failure.
7
+ // !
7
8
8
9
#include < iostream>
9
10
#include < string>
10
-
11
11
using std::string; using std::cout; using std::endl;
12
12
13
-
14
13
string make_plural (size_t ctr, const string &word, const string &ending = " s" )
15
14
{
16
15
return (ctr > 1 ) ? word + ending : word;
17
16
}
18
17
19
18
int main ()
20
19
{
21
- cout<< " singual: " << make_plural (1 , " success" ) << " "
22
- << make_plural (1 , " failure" ) << endl;
23
- cout<< " plural : " << make_plural ( 2 , " success " ) << " "
24
- << make_plural ( 2 , " failure " ) << endl ;
20
+ cout << " singual: " << make_plural (1 , " success" ) << " " << make_plural ( 1 , " failure " ) << endl;
21
+ cout << " plural : " << make_plural ( 2 , " success " ) << " " << make_plural (2 , " failure" ) << endl;
22
+
23
+ return 0 ;
25
24
}
You can’t perform that action at this time.
0 commit comments