Please send questions to
st10@humboldt.edu .
/*------------------------------------------------
signature: main: void -> int
purpose: to play with pointers, now also
featuring dynamic memory allocation!
examples: when you run this program,
the following should be printed to the
screen:
*num_ptr: 25.8
*val_ptr: 25.8
*num_ptr: 50
*val_ptr: 50
by: Sharon Tuttle
last modified: 12-3-10
------------------------------------------------*/
#include <iostream>
using namespace std;
int main()
{
double *num_ptr;
double *val_ptr;
num_ptr = new double;
*num_ptr = 25.8;
val_ptr = num_ptr;
cout << "*num_ptr: " << *num_ptr << endl;
cout << "*val_ptr: " << *val_ptr << endl;
cout << endl;
*val_ptr = 50.0;
cout << "*num_ptr: " << *num_ptr << endl;
cout << "*val_ptr: " << *val_ptr << endl;
delete num_ptr;
num_ptr = NULL;
val_ptr = NULL;
return EXIT_SUCCESS;
}