thanks Peter, I removed the function from the .cpp file and put the definition in the header, I now have another problem though:
puzzle.h(19): error C3520: 'args': parameter pack must be expanded in this context
main.cpp(30): note: see reference to function template instantiation 'void puzzle::create<const char*,const char*,const char*,const char*>(const char *,const char *,const char *,const char *)' being compiled
puzzle.h(18): error C3312: no callable 'begin' function found for type 'unknown-type'
puzzle.h(18): error C3312: no callable 'end' function found for type 'unknown-type'
puzzle.h(21): error C2065: 'i': undeclared identifier
on code of
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
template<typename... Args>
inline void create(Args... args)
{
for (auto &i : args)
{
correct_order->push_back(i);
}
}
nt main(void)
{
puzzle p;
p.create("test1", "test2", "test3", "test4");
p.print();
}
|
Can you advise the correct way to do template like this? Basically everytime I construct a puzzle I'll always pass in X number of strings only, using this create function