Ch07 Dynamic Control Flow - Chapter 7 Dynamic Control Flow...

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

View Full Document Right Arrow Icon
Chapter 7: Dynamic Control Flow
Image of page 1

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

View Full Document Right Arrow Icon
Overview Reading Companion: 2.7.4, 2.7.7-2.7.8 Reference Text: 3.6.7, 3.10 Learning Goals Write C programs that use function pointers Explain how Java implements polymorphism Identify the number of memory references that occur when a static method is called in Java and when an instance method is called Convert Java instance-method call into equivalent C code that uses function pointers Convert C programs that use function pointers into assembly code Explain why switch statements in C (and Java until version 1.7) restrict case labels to cardinal types (i.e, things that map to natural numbers) Convert C switch statement into equivalent C statement using gotos and an array of label pointers (a gcc extension to C) Convert C switch statement into equivalent assembly language that uses a jump table Determine whether a given switch statement would be better implemented using if statements or a jump table and explain the tradeoffs involved 2
Image of page 2
Back to Procedure Calls Static Method Invocations and Procedure Calls target method/procedure address is know statically in Java static methods are class methods invoked by naming the class, not an object in C specify procedure name public class A { static void ping () {} } static void foo () { A.ping (); } void ping () {} void foo () { ping (); }
Image of page 3

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

View Full Document Right Arrow Icon