23.03.2013 Views

Arrays, parameter passing, pointers and dynamic allocation. - ELIS

Arrays, parameter passing, pointers and dynamic allocation. - ELIS

Arrays, parameter passing, pointers and dynamic allocation. - ELIS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Dynamic De<strong>allocation</strong><br />

double *pi = new double(3.14159);<br />

int *num = new int(); *num = 9;<br />

int *grades = new int[40]; //finds space for 40 integers, returns<br />

address of first element to int pointer grades<br />

delete pi;<br />

delete num;<br />

delete [] grades; //NEED [] when deleting an array!<br />

70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!