Function objects, function templates, and passage by behavior in C++

  • Authors:
  • Richard Rasala

  • Affiliations:
  • Northeastern University, College of Computer Science, Boston, MA

  • Venue:
  • SIGCSE '97 Proceedings of the twenty-eighth SIGCSE technical symposium on Computer science education
  • Year:
  • 1997

Quantified Score

Hi-index 0.00

Visualization

Abstract

Passing functions and function objects to general purpose routines is a powerful abstraction mechanism that should be taught in freshman computer science. In C++, a "function" can be defined directly by the user or by a library or can be defined indirectly via operator() as a member function of a class. It is not obvious how to treat these "functions" in a uniform manner. We will show how function templates in C++ provide an elegant and teachable mechanism for passing entities with functional behavior as arguments to other functions.