Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 62 Data Structures Dr. Joshua Stough December 2, 2008.

Similar presentations


Presentation on theme: "CSCI 62 Data Structures Dr. Joshua Stough December 2, 2008."— Presentation transcript:

1 CSCI 62 Data Structures Dr. Joshua Stough December 2, 2008

2 Functions Same as in java but: –Can be defined outside of any class. –Can use default parameters int max(int a = 0, int b = 0); –Parameters after those given a default value must also be default. –Inline functions Rather than jump at run-time, paste in at compile time –inline int max(int a, int b) { return a > b ? a : b; } –More versatile parameter passing.

3 Parameter passing Call by value – typical Java way. –void swap (int a, int b); Call by reference – can change actual parameters –void swap (int &a, int &b); Call by const reference – function promises not to change actual parameter –int binSearch(const vector &arr, int key); Arrays passed by reference, but vectors passed by value (default).

4 Templates, Generics Lab.


Download ppt "CSCI 62 Data Structures Dr. Joshua Stough December 2, 2008."

Similar presentations


Ads by Google