-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverloadingAndoverwriting.cpp
More file actions
65 lines (49 loc) · 1.11 KB
/
Copy pathoverloadingAndoverwriting.cpp
File metadata and controls
65 lines (49 loc) · 1.11 KB
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
60
61
62
63
64
65
#include <iostream>
using namespace std;
// Function Prototype
void displayMsg1();
void displayMsg2(int);
void displayMsg3(int, char[20]);
int main()
{
int count;
char msg[20];
cout << "Output from function displayMsg1:" << endl;
for (int x = 1; x <= 4; x++)
displayMsg1();
cout << endl;
cout << "How many times do you want the message displayed?" << endl;
cin >> count;
cout << "Output from function displayMsg2:" << endl;
displayMsg2(count);
cout << endl;
cout << "How many times do you want the message displayed?" << endl;
cin >> count;
cout << "What message do you want displayed?" << endl;
cin.ignore();
cin.getline(msg, 20);
cout << "Output from function displayMsg3:" << endl;
displayMsg3(count, msg);
return 0;
}
// Definition of function displayMsg1
void displayMsg1()
{
cout << "Hello world!\n";
}
// Definition of function displayMsg2
void displayMsg2(int count)
{
for (int x = 1; x <= count; x++)
{
cout << "Hello world!\n";
}
}
// Definition of function displayMsg3
void displayMsg3(int count, char msg [20])
{
for (int x = 1; x <= count; x++)
{
cout << msg << endl;
}
}