forked from natto1784/ooplab
23 lines
299 B
C++
23 lines
299 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
class Foo {
|
|
int x;
|
|
|
|
public:
|
|
Foo(int _x) { x = _x; };
|
|
Foo operator+(Foo);
|
|
int get() { return x; }
|
|
};
|
|
|
|
Foo Foo::operator+(Foo bar) {
|
|
return Foo(x + bar.get());
|
|
}
|
|
|
|
int main() {
|
|
Foo bar = Foo(-3);
|
|
Foo baz = Foo(8);
|
|
|
|
cout << (bar + baz).get();
|
|
}
|