Pb avec ld : classe template en parametre d'une méthode membre
mjoubert
Messages postés2Date d'inscriptionvendredi 24 juin 2005StatutMembreDernière intervention24 juin 2005
-
24 juin 2005 à 17:15
mjoubert
Messages postés2Date d'inscriptionvendredi 24 juin 2005StatutMembreDernière intervention24 juin 2005
-
24 juin 2005 à 17:28
Bonjour à tous,
Mon problème est que ld n'arrive pas lier une méthode template d'une classe non template qui a en parametre une classe template.
How to reproduce :
List.hpp :
#ifndef LIST_HPP
#define LIST_HPP
template<typename _T_>
class List
{
};
#endif // LIST_HPP
a.hpp :
#ifndef A_HPP
#define A_HPP
#include "list.hpp"
class A
{
public :
template<typename _T_>
void method( List<_T_> & ) ;
};
#endif // A_HPP
a.cpp :
#include "a.hpp"
template<typename _T_>
void
A::method
( List<_T_> & )
{
}
<gras>.cpp :
#include "a.hpp"
#include "list.hpp"
int main()
{
A a ;
List l ;
a.method( l ) ;
return 0 ;
}
<gras>Makefile :
CC=g++
OPTS=-Wall -pedantic -ansi
OBJS=a.o main.o
all : $(OBJS)
$(CC) $(OPTS) $(OBJS) -o /dev/null
.cpp.o :
$(CC) $(OPTS) -c $<
dep :
makedepend -Y -m *.hpp *.cpp
clean :
rm -f *.o $(EXE)
# DO NOT DELETE
a.o: list.hpp
a.o: a.hpp list.hpp
main.o: a.hpp list.hpp
Alors ld me dit : " main.cpp: undefined reference to `void A::method(List&)' "