pgrm_009.cpp
Problem Statement
pgrm_009.cpp
WAP in cpp to overload the following functions int max(int a, int b); int max(int a, int b, int c); float max(float a, float b);
Source Code
cpp
#include<iostream>
using namespace std;
class Maximum {
public:
int max(int a, int b) {
return (a > b) ? a : b;
}
int max(int a, int b, int c) {
int m = a;
if(m < b) m = b;
if(m < c) m = c;
return m;
}
float max(float a, float b) {
return (a > b) ? a : b;
}
};
int main() {
Maximum obj;
cout << "Between 10, 20: " << obj.max(10, 20) << endl;
cout << "Between 10, 20, 30: " << obj.max(10, 20, 30) << endl;
cout << "Between 11.5, 10.5: " << obj.max(11.5f, 10.5f) << endl;
return 0;
}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
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
● Author - Amit Dutta · Updated - 10 Jul 2026