Reputation: 157
So I have something like:
template<int X>
class foo {
char a[X];
...
}
and I have another class 'bar' which contains a function like:
void execute(foo &b);
which should perform tasks on the char array in foo but it gives me an error saying it's a template class but using something like:
void execute(foo<int> &b);
gives an error as well. I'm not sure how exactly to pass it as the only thing which doesn't give me an error is if I statically give it a value like:
void execute(foo<4> &b);
Thanks a lot!
Upvotes: 2
Views: 1703
Reputation: 55887
Non-type template parameters should be known at compile-time. Right call for function will be something like
template<int N>
void execute(foo<N>& b);
// call
foo<4> b;
execute(b);
Upvotes: 7