#include <iostream>
using namespace std;

template <typename T>
class Test {
public:
    Test(const T &val) : m_val(val) {}

//     Test<T> operator +(const Test<T> &other) {
//         return Test(m_val + other.m_val);
//     }

    const T& val() const { return m_val; }

    template <typename N>
    friend Test<N> operator +(const Test<N> &a, const Test<N> &b);

private:
    T m_val;
};

template <typename T>
Test<T> operator +(const Test<T> &a, const Test<T> &b) {
    return Test<T>(a.m_val + b.m_val);
}

int main() {
    Test<int> t1(2);
    Test<int> t2(2);
    Test<int> t3 = t1 + t2;

    cout << "Sum is: " << t3.val() << endl;

    return 0;
}
