forked from natto1784/ooplab
22
lab7/20.cpp
Normal file
22
lab7/20.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#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();
|
||||
}
|
Reference in New Issue
Block a user