slides-10

slides-10 - Data Structures - CSCI 102 Housekeeping...

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

View Full Document Right Arrow Icon
1 Data Structures - CSCI 102 Copyright © William C. Cheng Housekeeping (Lecture 11 - 2/15/2011) Lab #5 (Operator Overloading) due this week during your lab session No design doc is required for this lab New lab grading policy will take effect starting with Lab #5 HW3 (Conway’s Game of Life) posted Due date is 3/7/2011 Start your coding early!
Background image of page 1

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

View Full DocumentRight Arrow Icon
HW2 (Extending the Video Game Database) due yesterday Monday, 2/14 20% penalty if tured in by end of tonight 1) 2) 2 Data Structures - CSCI 102 Copyright © William C. Cheng Housekeeping (Lecture 11 - 2/15/2011) Questions? What if your laptop died? Home Internet disrupted? Car broken? Cousin got stuck at the airport? And so on. .. Please do not ask for individual extension unless you have a documented proof of illness or a documented proof of family (not personal) emergency My "fairness" policy is: "Whatever I offer you, I must offer it to the whole class" This is why I cannot give individual extensions I must stick to this policy Please see (1) and (2)
Background image of page 2
3 Data Structures - CSCI 102 Copyright © William C. Cheng CS102 C++ Polymorphism Bill Cheng http://merlot.usc.edu/cs102-s11
Background image of page 3

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

View Full DocumentRight Arrow Icon
C Structs (Ch 10) Topics to cover 4 Data Structures - CSCI 102 Copyright © William C. Cheng C++ Object-Oriented Programming C++ Classes (Ch 11) Constructors Destructors Member functions Exception Handling (Ch 15) Namespaces (Ch 8) Operator Overloading (Ch 14) Polymorphism (Ch 13) Virtual functions Abstract classes Interfaces
Background image of page 4
The ability of an object of one type to appear and be used like an object of a different type What is polymorphism ? 5 Data Structures - CSCI 102 Copyright © William C. Cheng Polymorphism Based on inheritance, Triange Is-A Shape so. .. Remember our Shape and Triangle classes? We can actually pass Triangles around as Shapes! Triangle t( 5 , 5 , 15 , 20 ); Shape tval = t; Shape &tref = t; Shape *tptr = &t; Shape *tptr2 = new Triangle( 1 , 2 , 55 , 62 ); Write algorithms & frameworks that manipulate base class You can write very advanced code with polymorphism Can even write code for subclasses that hasn’t been realized or designed!
Background image of page 5

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

View Full DocumentRight Arrow Icon
So what does this code do? 6 Data Structures - CSCI 102 Copyright © William C. Cheng Polymorphism Triangle t( 5 , 5 , 15 , 20 ); t.print(); Shape tval = t; tval.print(); Shape &tref = t; tref.print(); Shape *tptr = &t; tptr->print(); It should call the Triangle object’s overloaded print method, right? Does it?
Background image of page 6
Even though we can pass around a Triangle as a Shape, it doesn’t help if we can’t make it call Triangle’s overloaded methods 7 Data Structures - CSCI 102 Copyright © William C. Cheng Early/Static/Compile-Time Binding When your code is compiled, the compiler directly associates a function call with a memory location to make function calls a fast lookup Why does this happen? Isn’t there some way to tell the compiler to wait until
Background image of page 7

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

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

This note was uploaded on 02/17/2011 for the course CSI 102 taught by Professor Billcheng during the Spring '11 term at USC.

Page1 / 24

slides-10 - Data Structures - CSCI 102 Housekeeping...

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

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