Skip to content

Instantly share code, notes, and snippets.

@PandaWhoCodes
Created October 30, 2026 10:24
Show Gist options
  • Select an option

  • Save PandaWhoCodes/6a8ec79cedc5604c4941beabb101106e to your computer and use it in GitHub Desktop.

Select an option

Save PandaWhoCodes/6a8ec79cedc5604c4941beabb101106e to your computer and use it in GitHub Desktop.
add.cpp
#include <iostream>
using namespace std;
class Calculator {
public:
// Version 1: Adds 2 numbers
int add(int a, int b) {
return a + b;
}
// Version 2: Adds 3 numbers (Overloaded version)
int add(int a, int b, int c) {
return a + b + c;
}
};
int main() {
Calculator calc;
cout << "Sum of 2 numbers: " << calc.add(10, 20) << endl; // Calls Version 1
cout << "Sum of 3 numbers: " << calc.add(10, 20, 30) << endl; // Calls Version 2
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment