Gives an error saying function on lefthand side.Code:int * p=new int(); int* function () { *p=10; cout<<"old p :"<<*p<<endl; return p; } int main() { int c=25; function()=&c; cout<<*p<<endl; }
Works fine.Code:int * p=new int(); int& function () { *p=10; cout<<"old p :"<<*p<<endl; return *p; } int main() { int c=25; function()=c; cout<<*p<<endl; }
Why does the second one works fine but not the first one?
The code that i wrote may not make any sense.. Sorry.. I just wanted to know why the first one won't compile..