diff --git a/04cpp3/sec03Templates.md b/04cpp3/sec03Templates.md index 9ec883d3a..42f39fb58 100644 --- a/04cpp3/sec03Templates.md +++ b/04cpp3/sec03Templates.md @@ -85,11 +85,13 @@ A common example of a templated function would be a function which acts on a con template vector everyOther(vector &v_in) { - vector v_out; + vector 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.