labs 7: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-26 16:53:39 +05:30
parent 21afaa311b
commit 7ba9554ed5
7 changed files with 158 additions and 1 deletions

22
lab7/20.cpp Normal file
View 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();
}