-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlab01.cpp
More file actions
48 lines (34 loc) · 659 Bytes
/
Copy pathlab01.cpp
File metadata and controls
48 lines (34 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// lab01.cpp - convert this code to C11
/*
* This code should compile cleanly with the following options:
*
C: -std=c11 -g -Wall -Wextra -Wpedantic
C++: -std=c++11 -g -Wall -Wextra -Wpedantic
*/
#include <iostream>
#include <string>
using namespace std;
void bump(int& i, int amount=1)
{
i += amount;
}
void bump(string& s, char c='o')
{
s.push_back(c);
}
int main()
{
int i = 1;
cout << i << endl;
bump(i);
cout << i << endl;
bump(i, 2);
cout << i << endl;
string s = "foo";
cout << s << endl;
bump(s);
cout << s << endl;
bump(s, 'x');
cout << s << endl;
return 0;
}