Skip to content
Free planNo credit card requiredStart writing

book chapter · Apress eBooks · 2020

Function Templates

Ray Lischner

Cited by 0Abstract and details only

Abstract

You saw in Exploration 25 that the magic of overloading lets C++ implement an improved interface to the absolute value function. Instead, of three different names (abs, labs, and fabs), C++ has a single name for all three functions. Overloading helps the programmer who needs to call the abs function, but it doesn’t help the implementer much, who still has to write three separate functions that all look and act the same. Wouldn’t it be nice if the library author could write the abs function once instead of three times? After all, the three implementations may be identical, differing only in the return type and parameter type. This Exploration introduces this style of programming, called generic programming.

Cite this paper

APA 7

Lischner, R. (2020). Function Templates. Apress eBooks, 391–400. https://doi.org/10.1007/978-1-4842-5961-0_51

MLA 9

Lischner, Ray. “Function Templates.” Apress eBooks, 2020, pp. 391–400, https://doi.org/10.1007/978-1-4842-5961-0_51.

Chicago

Lischner, Ray. 2020. “Function Templates.” Apress eBooks: 391–400. https://doi.org/10.1007/978-1-4842-5961-0_51.

Harvard

Lischner, R. (2020) ‘Function Templates’, Apress eBooks, pp. 391–400. Available at: https://doi.org/10.1007/978-1-4842-5961-0_51.

BibTeX
@incollection{lischner2020function,
  title = {{Function Templates}},
  author = {Lischner, Ray},
  booktitle = {Apress eBooks},
  pages = {391--400},
  year = {2020},
  doi = {10.1007/978-1-4842-5961-0_51}
}

Made from the index record. Check names, capitalisation and page numbers against the paper. Need another style? AI for Research has over 10,000.