pgrm_008.cpp (686B)
1 /* 2 * Author: Amit Dutta <amitdutta4255@gmail.com> | Date: 06 Jul 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Function Overloading. */ 8 9 #include <iostream> 10 using namespace std; 11 12 class Addition { 13 public: 14 int add(int a, int b) { 15 return a + b; 16 } 17 int add(int a, int b, int c) { 18 return a + b + c; 19 } 20 float add(float a, float b) { 21 return a + b; 22 } 23 }; 24 25 int main() { 26 Addition obj; 27 cout << "10 + 20 : " << obj.add(10, 20) << endl; 28 cout << "10 + 20 + 30 : " << obj.add(10, 20, 30) << endl; 29 cout << "12.5 + 10.5 : " << obj.add(10.5f, 12.5f) << endl; 30 return 0; 31 }