1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture Object oriented programming - Lecture No 21

23 27 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 23
Dung lượng 78,26 KB

Nội dung

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

Ngày đăng: 20/09/2020, 13:28