summaryrefslogtreecommitdiffstats
path: root/examples/15_borrow-error.cpp
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-07-02 02:54:21 -0400
committerJesse Luehrs <doy@tozt.net>2014-07-02 02:54:21 -0400
commite620daf3b1a40ae825c625bc4328fb7d2b3ee8b6 (patch)
treefaa469408ee78623eaa8d2720dcbb36096788ca1 /examples/15_borrow-error.cpp
downloadintro-to-rust-yapc-na-2014-master.tar.gz
intro-to-rust-yapc-na-2014-master.zip
initial commitHEADmaster
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;
+}
+