-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_overload.cpp
More file actions
43 lines (38 loc) · 770 Bytes
/
Fun_overload.cpp
File metadata and controls
43 lines (38 loc) · 770 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
#include <iostream>
using namespace std;
class test
{
private:
int i, j;
public:
void get(int a, int b)
{
i= a;
j= b;
}
void get()
{
cout<<"Enter i and j: ";
cin>>i>>j;
}
void get(int a)
{
i= a;
j= 0;
}
void display()
{
cout<<"i = " << i <<"j = "<< j << endl;
}
};
int main()
{
test t1, t2, t3;
t1.get(10, 20); // Calls the first get method
t2.get(); // Calls the second get method
t3.get(30); // Calls the third get method
t1.display(); // Calls the display method for first object
t2.display(); // Calls the display method for 2nd object
t3.display(); // Calls the display method for 3rd object
return 0;
}