by lasagnaphil · 7y ago · 0 comments
#include <iostream>
using namespace std;
int* foo() {
int y = 2;
return &y;
}
int main() {
int* x = foo();
cout << *x << endl;
return 0;
}
I would recommend not using this for educational purposes yet; it could mislead students about pointer usage.