-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionOverloadingDEMO.m4.cpp
More file actions
65 lines (46 loc) · 1.34 KB
/
Copy pathFunctionOverloadingDEMO.m4.cpp
File metadata and controls
65 lines (46 loc) · 1.34 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
//************************************************************************
// Author: Rolando Carreon
// Date: mar 18 2025
// Language: C++
// Assignment: FunctionOverloadingDEMO.m4
// Description:useing function overloading
//************************************************************************
#include<iostream>
#include<string>
using namespace std;
// function prototypes
void myFunction();
void myFunction(string);
string myFunction(string, int);
int main()
{
// declare local variables
myFunction();
cout << endl;
myFunction("Hello");
cout << endl;
// no cout on function definitions so u have to cout from here
cout << myFunction("Here is a string", 5) << endl;
cout << endl;
return 0;
}
// function definitions
void myFunction()
{
cout << "Inside the myFunction that does not have an argument.\n";
}
void myFunction(string message)
{
cout << "Inside the myFunction that HAS an argument: "
<< message << endl;
}
string myFunction(string message, int number)
{
// declare local variable
// not a cout so dont use '<<' use '+' instead
string myReturn = "Inside myFunction = the messahe is " +
message + "\n";
myReturn += "The value of the int passed to me is " +
to_string(number) + "\n";
return myReturn;
}