Docsity

Callbacks: Separating and Reusing Code in OOP - Prof. Fawzi Philip Emad, Study notes of Computer Science

Partial preview of the text

Download Callbacks: Separating and Reusing Code in OOP - Prof. Fawzi Philip Emad and more Study notes Computer Science in PDF only on Docsity!

CMSC 132:

Object-Oriented Programming II

Callbacks

Department of Computer Science

University of Maryland, College Park

Callback

Definition

Executable code passed as argument to other code

Approach

  1. Higher-level code passes function as argument to lower-level code In Java, pass object implementing interface In C/C++, pass pointer to function
  2. Lower-level code invokes callback function to perform desired task