Assume there are 3 source files:
main.cpp:
#include <iostream>
#include <string>
#include <vector>
#include "funcs.hpp"
void possible_characters(std::string &digits) {
std::vector<std::string> res;
print_vec(res);
}
int main() {
std::string ss = "2";
possible_characters(ss);
return 0;
}
funcs.hpp
#include <vector>
template <typename T> void print_vec(std::vector<T> &v);
funcs.cpp:
#include "funcs.hpp"
template <typename T> void print_vec(std::vector<T> &v) {
for (auto &x : v) {
std::cout << x << ", ";
}
std::cout << std::endl;
}
When compiling these srcs using the following cmd:
g++ main.cpp funcs.cpp -o tele_digit
the error occurs:
undefined reference to `void print_vec()...`