Untitled

 avatar
unknown
plain_text
2 years ago
704 B
4
Indexable
#include <iostream>
#include <string>

using namespace std;

class MathOperations {
public:
    int add(int a, int b) {
        return a + b;
    }

    double add(double a, double b) {
        return a + b;
    }

    string add(const string& str1, const string& str2) {
        return str1 + str2;
    }
};

int main() {
    MathOperations math;

    int intResult = math.add(5, 3);
    cout << "Addition of integers: " << intResult << endl;

    double doubleResult = math.add(3.14, 2.71);
    cout << "Addition of floating-point numbers: " << doubleResult << endl;

    string strResult = math.add("Hello, ", "world!");
    cout << "Concatenation of strings: " << strResult << endl;

    return 0;
}
Editor is loading...