I have this class:
class A
{
private:
int a;
public:
int getA();
void setA(int a=2) ;
};
and a function:
A& func()
{
A a;
a.setA(777);
return a;
}
and in main:
A a;
a=func();
cout<<a.getA();
and i get "777". but as i know it shouldnt get me any value since the local "a" in the function has been deleted. so why do i get the right value?