Possible Duplicate:
Returning the address of local or temporary variable
Can a local variable's memory be accessed outside its scope?
return reference to local variable
Is it an undefined behavior when you return a ref. to a local variable ?
int & func(){
int x = 10;
return x;
}
int main() {
int &y = func();
cout << y << endl;
}