COMP 2404 Lecture Notes - Lecture 7: Orson Scott Card, Isaac Asimov, Include Directive

80 views7 pages

Document Summary

Function templates -> the goal is to create a function that works with any data type. If a member function is templated its class must be too. What the compiler does is it creates a specialisation of the template for each data type you use. We can overload templated functions with non-templated functions. Templated functions can be overloaded with same name but different parameters. Compiler gives preference to a non-templated function over templated one (that s the convention) Class templates -> the goal is to create a class that works with any data type. Any member function or data member can use that data type of the class. We can instantiate of that class using any data type. This is the first and the only time in this course we are breaking the rule of not implementing class implementations in the header file. Templates only work when implemented in the header file and not otherwise.

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