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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Function Templates<br />

S Template<br />

template //or template <br />

T boxVolume(T side) {<br />

return side * side * side;<br />

}<br />

S C++ compiler automatically generates separate function template<br />

specializations for each type the function is called with.<br />

S T is placeholder for actual data type<br />

S int result = boxVolume(3); double result = boxVolume(6.2);<br />

85

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

Saved successfully!

Ooh no, something went wrong!