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.
- 1.Barton, John. J. and Nackman, Lee R., Scientific alrl Engineering C++: An Introduction With Advanced Techniques and Examples,, Addison-Wesley, Reading, MA, 1994. Google ScholarDigital Library
- 2.Ellis, Margaret A. and Stroustrup, Bjame, The Annotated C++ Reference Manual, ANSI Base Document, Addison-Wesley, Reading, MA, 1990. Google ScholarDigital Library
- 3.Meyers, Scott, Effective C++: 50 Ways to Improve Your Programs and Designs, Addison-Wesley, Reading, /VIA, 1992. Google ScholarDigital Library
- 4.Meyers, Scott, More Effective C++: 35 New Ways to Improve Your Programs and Designs, Addison-Wesley, Reading, MA, 1996. Google ScholarDigital Library
- 5.Musser, David and Saini, Atul, STL Tutorial atzl Reference Guide: C++ Programming with the Standard Template Library, Addison-Wesley, Reading, MA, 1996. Google ScholarDigital Library
- 6.Pattis, Richard, Teaching C++ as an Introductory Programming Language (an electronic newsletter), Vol 1::2, February 15, 1996. Contaet: [email protected],Google Scholar
- 7.Stroustrup, Bjarne, The C++ Programming Langttage, 2nd Edition, Addison-Wesley, Reading, MA, 1991. Google ScholarDigital Library
- 8.Stroustrup, Bjarne, The Design and Evolution of C++, Addison-Wesley, Reading, MA, 1994. Google ScholarDigital Library
Index Terms
- Function objects, function templates, and passage by behavior in C++
Recommendations
Function objects, function templates, and passage by behavior in C++
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 ...
RBF neural network based on q-Gaussian function in function approximation
To enhance the generalization performance of radial basis function (RBF) neural networks, an RBF neural network based on a q-Gaussian function is proposed. A q-Gaussian function is chosen as the radial basis function of the RBF neural network, and a ...
The function concept in C++: an empirical study
WGP '09: Proceedings of the 2009 ACM SIGPLAN workshop on Generic programmingHigher-order functions are essential for generic programming. While they are naturally supported in functional programming languages, there are no higher-order functions in C++. There, various function datatypes exist that simulate the effect of higher-...
Comments