is the below code wrong ? I am returning reference to local variable ...it should core dump , but it is executing fine . Is the below code is working fine on my system because I am LUCKY ??
#include<iostream>
using namespace std;
class a{
public:
int i;
int arr[20];
a()
{
cout<<"\ninside constructor";
i=10;
}
public:
static a& ret()
{
a chk;
return chk;
}
void say()
{
i=10;
arr[0]=1;
cout<<"\nHello World\n";
}
};
int main()
{
(a::ret()).say();
return 1;
}