Templates problem

Pascal Francq pfrancq@ulb.ac.be
Wed Feb 23 05:25:00 GMT 2000


I define a template with two files ".h" for the declaration and ".hh" (include
in ".h") for the definition (see below).
I seems that the compiler (gcc 2.95.2) have problems with generating correct
code and debug information. For example in the init function, also if nb is
different than null, the program doesn't run the for loop.
It is possible? Perhaps is the way I manage the files for the templates is
wrong?



// foo.h
template<class T> : class foo
{
  T **tab;
  unsigned int nb;
...
  void init(void);
}

#include "foo.h"


//foo.hh
....
template<class T> void foo<T>::init(void)
{
  T **ptr;
  unsigned i;

  for(i=nb+1,ptr=Tab;--i;ptr++)
  {
    (*ptr)->doSomething1();
    (*ptr)->doSomething2();
  }
}

-- 


Ir. Pascal Francq
Researcher
Université Libre de Bruxelles
Faculty of Applied Mechanics
Avenue F.D. Roosevelt, 50
CP 165/41
B-1050 Brussels
BELGIUM
Tel. +32-2-650 47 65
Fax +32-2-650 27 10


More information about the Gcc mailing list