Hi, ClassDef needs just the template name: template<class T> class temp { T a; public: test() {}; T Get(); void Set(T new_a); ClassDef(test,1) }; ClassImp's only purpose is to indicate the name of the implementation file. Its arguments needs to be a concrete class. i.e.: ClassImp(temp<int>); To Register an implementation file for the template itself you need to use templateClassImp, which takes the template name as it's argument. templateClassImp(temp); Cheers, Philippe -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Micha D. Niskin Sent: Wednesday, May 21, 2003 3:31 PM To: roottalk@cern.ch Subject: [ROOT] Is it possible to use ClassDef and ClassImp with a template class? Hello. I am using root version 3.05/05 on linux (RedHat 9, i386), with gcc version 3.2.2. Here is a simple example: //-----------------------test.h #include <Rtypes.h> template<class T> class temp { T a; public: test() {}; T Get(); void Set(T new_a); ClassDef(test<T>,1) }; //-----------------------test.C #include "test.h" template<class T> ClassImp(test<T>) template<class T> T test<T>::Get() { return a; } template<class T> void test<T>::Set(T new_a) { a=new_a; } When I try to compile this I get the following error: [mdn@hermit root_template_test_class]$ make g++ -O -Wall -fPIC -D_REENTRANT -I/home/mdn/root/include -c -o test.o test.C test.C:4: parse error before `namespace' test.C:4: `T' was not declared in this scope test.C:4: template argument 1 is invalid test.C:4: ISO C++ forbids declaration of `parameter' with no type test.C:4: `T' was not declared in this scope test.C:4: template argument 1 is invalid test.C:4: ISO C++ forbids declaration of `type name' with no type make: *** [test.o] Error 1 I have attached the Makefile and sources. I would appreciate any help at all in figuring this out. I am a bit confused by the macros root and cint use here. A pointer to the relevant documentation would be very helpful. Thanks in advance! -- Regards, Micha D. Niskin <mniskin@yahoo.com>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET