code:
#include <stdio.h>
T foo(T x,T y);
int main(void)
{
}
template <typename T>
T func(T x,T y) {return x + y;}
error:
3 | T foo(T x,T y);
| ^
main.c:3:7: error: unknown type name ‘T’
3 | T foo(T x,T y);
| ^
main.c:3:11: error: unknown type name ‘T’
3 | T foo(T x,T y);
| ^
main.c:9:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
9 | template <typename T>
| ^
I thought I should declare the template, so I tried to declare the template before declaring the function:
#include <stdio.h>
template <typename T>
T foo(T x,T y);
int main(void)
{
}
T func(T x,T y) {return x + y;}
But this is still wrong, so wondering how should I declare the template