10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

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.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

Passing Arrays as Parameters<br />

• Passes base address of array to function (address of first element in the<br />

array)<br />

• Always a call by reference parameter (no & needed)<br />

• The formal parameter in the function does not need to state the size.<br />

• Prefixing the array declaration with “const” in the formal parameter<br />

prevents the function from modifying the array.<br />

• Cannot be the returned value of a function.<br />

Examples:<br />

someFunction(anArray); // VALID call<br />

void someFunction(int anArray[ ]); // Function can change the elements<br />

void someFunction (const int anArray[ ]); // Function cannot change the<br />

elements<br />

#include <br />

main()<br />

{<br />

int a[5];<br />

int i;<br />

for(i = 0;i

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

Saved successfully!

Ooh no, something went wrong!