Lecture12

Lecture12 - Outline CS11600: Introduction to Computer...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS11600: Introduction to Computer Programming (C++) Lecture 12 Svetlozar Nestorov University of Chicago 2/5/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 2 Outline ± Robust class design ± Template functions: • Motivation • Instantiation •Ove r load ing • Specialization ± Friend functions 2/5/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 3 Robust Class Design ± Implement two private member functions copy and free that handle dynamic memory allocation and deallocation for the class. class ClassName { void copy(const ClassName &); void free(); … } ± Call these functions in constructors, destructor, and assignments. 2/5/2003 Svetlozar Nestorov, CS 116: Intro to Programming II 4 Generic Functions ± Find max of two numbers: x > y ? x : y ± Works for int, double, char*, etc. ± But, consider a max function: int max(int x, int y) { return x > y ? x : y; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Lecture12 - Outline CS11600: Introduction to Computer...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online