Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
704 B
1
Indexable
Never
#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;
}