Created
October 30, 2026 10:24
-
-
Save PandaWhoCodes/6a8ec79cedc5604c4941beabb101106e to your computer and use it in GitHub Desktop.
add.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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