bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_2 / eduincs / pgrm_008.cpp

pgrm_008.cpp (550B)


      1 /* Function Overloading. */
      2 
      3 #include <iostream>
      4 using namespace std;
      5 
      6 class Addition {
      7     public:
      8         int add(int a, int b) {
      9             return a + b;
     10         }
     11         int add(int a, int b, int c) {
     12             return a + b + c;
     13         }
     14         float add(float a, float b) {
     15             return a + b;
     16         }
     17 };
     18 
     19 int main() {
     20     Addition obj;
     21     cout << "10 + 20 : " << obj.add(10, 20) << endl;
     22     cout << "10 + 20 + 30 : " << obj.add(10, 20, 30) << endl;
     23     cout << "12.5 + 10.5 : " << obj.add(10.5f, 12.5f) << endl;
     24     return 0;
     25 }