Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 04cpp3/sec03Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ A common example of a templated function would be a function which acts on a con
template<typename T>
vector<T> everyOther(vector<T> &v_in)
{
vector<int> v_out;
vector<T> v_out;
for(size_t i = 0; i < v_in.size(); i++)
{
if(i % 2 == 0) v_out.push_back(v_in[i]);
}

return v_out
}
```
- The exact details of the type `T` don't matter in this case, since we never access the data of type `T` anyway. The only restriction on `T` is that it can be added to a vector.
Expand Down