I'm learning c++ and I'm working with templates. When I declare function in a header file with template, and implement it in cpp, it keeps saying "undefined reference to void do_something<SomeEnum>()"
.h file:
enum SomeEnum {
Yes,
No,
Maybe
};
template<SomeEnum someEnum>
void do_something();
void do_something();
.cpp file:
#include "test.h"
#include "stdio.h"
template<SomeEnum someEnum>
void do_something() {
printf("%d\n", someEnum);
}
void do_something() {
printf("...\n");
}
main file:
...main function
do_something(); // no error
do_something<Yes>(); // thrown an error