I'm adding a "templated non-member function" to a .h file. Why isn't my program outputting anything after I've added the code below:
This function is takes in two arguments, a vector of type Vec<T> and an element of type T, and returns the number of elements that matched the argument and were successfully removed from the vector. The order of the other elements should stay the same. I've added this to the .h file and tried to call this function from a test.cpp file with the lines: int num_ele = remove_matching_elements(v, 22); cout << num_ele << endl; //where v is {11, 22, 33, 11, 55, 33} template <class T> int remove_matching_elements(Vec<T>& v, const T& t) { int counter = 0; int i; for(i = 0; i < v.size(); i++){ if(v[i] =
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.