Chainage ch; // Here I use the type i've defined up there
...
}#include "alist.tpp"
And the template will define all the methods. But I have the following compilation problem :
"alist.hpp:16:9: erreur: expected unqualified-id before ‘template’
alist.hpp:20:4: erreur: ‘Maillon’ does not name a type
alist.hpp:23:2: erreur: ‘Maillon’ does not name a type
alist.hpp:24:2: erreur: ‘Maillon’ does not name a type"
You're misusing the keyword 'typedef'. If you saw somewhere someone writing typedefstruct a {...} b;, that was C code. in C++, we write struct b {...};.
template <class K, class V>
struct _maillon{
K clef;
V valeur;
struct _maillon *succ;
};
typedef _maillon<int, int> Maillon;
typedefstruct {
Maillon *tete;
Maillon *queue;
int nb_elts;
} Chainage;
the code i posted above compiles just fine and should suite your needs.
You cant typedef a template struct when defining the template struct from what ive been told. you define the struct then typedef once the struct has been defined.
also i used ints as the types but that could be changes as needed. thats one of the things you were missing.