pgrm_008.cpp
Problem Statement
pgrm_008.cpp
Function Overloading.
Source Code
cpp
#include <iostream>
using namespace std;
class Addition {
public:
int add(int a, int b) {
return a + b;
}
int add(int a, int b, int c) {
return a + b + c;
}
float add(float a, float b) {
return a + b;
}
};
int main() {
Addition obj;
cout << "10 + 20 : " << obj.add(10, 20) << endl;
cout << "10 + 20 + 30 : " << obj.add(10, 20, 30) << endl;
cout << "12.5 + 10.5 : " << obj.add(10.5f, 12.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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
● Author - Amit Dutta · Updated - 06 Jul 2026