CS 1337 Lecture 17: 2018-04-02 Templates Pt1

22 views2 pages

Document Summary

When our code calls a function template, the compiler automatically generates. A pattern for a function that can work with many data types. When we write a function template, we leave out the exact data types and. // description : hello world in c++, ansi-style. * can have a function of the same name as long as it has different parameters. * function templates instead we use place holders code for the specific data type we"re. * all the data types in the template prefix must be used in the template definition. * function call must pass parameters for all the data types specified in the prefix. * like regular functions, function templates must be defined before they are called. * no actual code is generated from the function template. * a template does not use any memory. * instead, when a template is called, the compiler generates code for those particular type(s)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents