summaryrefslogtreecommitdiffstats
path: root/examples/15_borrow-error.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/15_borrow-error.cpp')
-rw-r--r--examples/15_borrow-error.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/15_borrow-error.cpp b/examples/15_borrow-error.cpp
new file mode 100644
index 0000000..74213ce
--- /dev/null
+++ b/examples/15_borrow-error.cpp
@@ -0,0 +1,14 @@
+#include <iostream>
+
+int *foo(void)
+{
+ int x = 2;
+ return &x;
+}
+
+int main(int argc, char *argv[])
+{
+ int *x = foo();
+ std::cout << *x << std::endl;
+}
+