#include <iostream>
using namespace std;
class Base
{
int* data;
public:
Base(int size, int value=0)
{
data = new int(value);
}
~Base() { delete data; }
Base &operator+=(Base src)
{
*data += *src.data;
return *this;
}
operator int() { return *data; }
};
int main()
{
Base a(2);
Base b(2, 10);
a += b;
cout << b << endl;
return 0;
}
Login in to like
Login in to comment