-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_overloading.cpp
More file actions
84 lines (63 loc) · 984 Bytes
/
function_overloading.cpp
File metadata and controls
84 lines (63 loc) · 984 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// without using the class
/*
#include<iostream>
using namespace std;
void display(int );
void display(float );
void display(int , float );
int main()
{
int a=5;
float b=5.5;
display(a);
display(b);
display(a,b);
return 0;
}
void display(int var1, float var2)
{
cout<<"a="<<var1<<endl;
cout<<"b="<<var2<<endl;
}
void display(int var1)
{
cout<<"a="<<var1<<endl;
}
void display(float var2)
{
cout<<"b="<<var2<<endl;
}
*/
// with using the class
#include<iostream>
using namespace std;
class variable
{
public:
void display(int );
void display(float );
void display(int , float );
};
void display(int var1, float var2)
{
cout<<"a="<<var1<<endl;
cout<<"b="<<var2<<endl;
}
void display(int var1)
{
cout<<"a="<<var1<<endl;
}
void display(float var2)
{
cout<<"b="<<var2<<endl;
}
int main()
{
int a=5;
float b=5.5;
variable v1;
v1.display(a);
v2.display(b);
v1.display(a,b);
return 0;
}