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.

Function Templates<br />

S We can do function overloading<br />

int boxVolume(int side) {<br />

return side * side * side;<br />

}<br />

double boxVolume(double side) {<br />

return side * side * side;<br />

}<br />

S Why define 2 functions that look identical, but have different types?<br />

S Overloading that is more compact <strong>and</strong> convenient = function<br />

templates. Only write it once!<br />

84

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

Saved successfully!

Ooh no, something went wrong!