ECS 36B Lecture 20: Templating and Iterators

58 views2 pages
Verified Note

Document Summary

Ecs 36b - lecture 20 - templating and iterators. Today, the professor will show how to work with templates by programming a practical example -- will be helpful for the current homework assignment. A vector is like an array in c++ except that it is dynamically sized automatically -- when something is inserted or deleted, that space is immediately added or removed. Series of elements are stored under the same variable name. There is a vector class within the std namespace. A lot of these concepts will be applicable to our homework 2. What to consider when writing the vector program: We want the vector to be able to be made for each type but don"t want to write separate classes for each type use templating! All of the code goes in the header files. Declaring a class as templated: template class vector{ Creating constructors -- have to know how to accept vectors of type t.

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