After you have read and studied this chapter, you should be able to: Perform linear and binary search algorithms on small arrays, determine whether a linear or binary search is more effective for a given situation, perform selection and bubble sort algorithms, describe the heapsort algorithm and show how its performance is superior to the other two algorithms, apply basic sorting algorithms to sort an array of objects.
CSC241: Object Oriented Programming Lecture No 21 Previous Lecture • Polymorphism Example program – • Virtual destructor – • person class base class destructor is virtual, derived class destructor also become virtual Friend functions – can access private member of a class Today’s Lecture • Friend function – example program: Distance class – Friend function for functional notation • Friend classes • static functions Distance Example class Distance { private: int feet; float inches; public: Distance() : feet(0), inches(0.0) {} Distance (float fltfeet) { feet = fltfeet; inches = 12*(fltfeet-feet); } Distance(int ft, float in) : feet(ft), inches(in) { } void showdist() const { cout