I have a real beginner question for you all.
I found the example above on a website. I thought that a double declared in a function is allocated space on the run-time stack and is destroyed after the function returns. So if you then have
double * GetSalary()
double salary = 26.48;
double *HourlySalary = &salary;
aren't you then going to have ptr pointing to an address in memory that will be holding different data?
double * ptr = GetSalary();
Also, when GetSalary() returns, does the pointer HourlySalary get destroyed just like any other primitive upon return?