ECS 36B Lecture 20: Templating and Iterators
ECS 36B verified notes
20/26View all
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.