Bonjour, j'ai un souci de compilation avec ce code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
template <class T>
void initTab(T *t,int n){
	srand(time(NULL));
	for(int i=0;i<n;i++){
		t[i]=rand()%101;
	}
}
Quand j'essaye de le compiler en fichier .obj en tapant sur une console:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
g++ -c code.cpp -o code.obj
sur windows ca marche sans problème mais sur linux j'ai un message d'erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
algo1.cpp: In function ‘void initTab(T*, int)’:
algo1.cpp:24: erreur: there are no arguments to ‘srand’ that depend on a template parameter, so a declaration of ‘srand’ must be available
algo1.cpp:24: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
algo1.cpp:26: erreur: there are no arguments to ‘rand’ that depend on a template parameter, so a declaration of ‘rand’ must be available
Si quelqu'un pourrait m'éclaircir tout ça j'en serais reconnaissant.