-
Notifications
You must be signed in to change notification settings - Fork 0
/
H05_3.cpp
59 lines (42 loc) · 974 Bytes
/
H05_3.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>
using namespace std;
int askGetNumber(string prompt = "Please input a number: ")
{
int number;
cout << prompt << endl;
cin >> number;
return number;
}
int askGetNumberOverload()
{
int number;
cout << "Please input a number: " << endl;
cin >> number;
return number;
}
int askGetNumberOverload(string prompt)
{
int number;
cout << prompt << endl;
cin >> number;
return number;
}
void spenglerPause()
{
//Spengler pause
char dum;
std::cin >> dum;
}
int main()
{
//Function call with no arguments to demonstrate default arguments
askGetNumber();
//Function call with a prompt argument
askGetNumber("Please enter a number: ");
//Function call with no arguments
askGetNumberOverload();
//Function call with a prompt argument to demonstrate function overloading
askGetNumberOverload("Please enter a number: ");
spenglerPause();
}