I'm fluent in Java, but very new to C++. I'm definitely not understanding what is wrong -- at all.
Here's the code:
// Sort_Search.h
#ifndef SORT_SEARCH_H
#define SORT_SEARCH_H
using std::vector;
template<typename T> void printVector(vector<T> &list);
#endif
// Sort_Search.cpp
#include <iostream>
#include <vector>
using std::vector;
template<typename T>
void printVector(vector<T> &list) {
// print every member of the list
for(int i = 0; i < (int)list.size(); i++) {
// insert a comma where needed
if(i != 0)
cout << ", ";
cout << list[i];
}
}
I keep getting the same errors:
sort_search.h(6): error C2182: 'printVector' : illegal use of type 'void'
sort_search.h(6): error C2998: 'int printVector' : cannot be a template definition
There are more templates causing similar errors in the same files. I figured if I can fix one, I'll figure out how to fix the rest. I've tried every single thing I can think of.
Thanks so much for any help. I'm going crazy over here. haha.