Website Summary Files Commits Branches @commit @diff @stats
path: root / Week11 / Exercise03 / main.cpp
diff options
context:
space:
mode:
1 files changed, 17 insertions, 0 deletions
-rw-r--r--Week11/Exercise03/main.cpp17
diff --git a/Week11/Exercise03/main.cpp b/Week11/Exercise03/main.cpp
new file mode 100644
index 0000000..d8a4d66
--- /dev/null
+++ b/Week11/Exercise03/main.cpp
@@ -0,0 +1,17 @@
+#include "SharedPointer.hpp"
+#include <iostream>
+
+void inc(SharedPointer<int> val) {
+ (*val)++;
+}
+
+int main() {
+ SharedPointer<int> x(new int);
+ SharedPointer<int> y = x;
+ *x = 5;
+ std::cout << *x << ' ' << *y << std::endl;
+ inc(y);
+ std::cout << *x << ' ' << *y << std::endl;
+
+ return 0;
+}