RE: [ROOT] template class

From: Philippe Canal (pcanal@fnal.gov)
Date: Tue Feb 18 2003 - 05:33:33 MET


Hi,

// ClassDefT(TestClass, Type)

The 2nd parameters of ClassDefT is suppose to be a version number.

Since ROOT 3.03.07 the macro ClassDefT, ClassDefT2 and ClassImpT are
obsolete.
Just use ClassDef(classname,version_number).

So your TestClass.h can look like:

template<class Type>
class TestClass : public TObject
{
public:
  TestClass();
  ~TestClass();
private:
  Type *_tree;

  ClassDef(TestClass, 1);
};

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Jedong Lee
Sent: Monday, February 17, 2003 8:57 PM
To: Rene.Brun@cern.ch
Cc: Roottalk
Subject: [ROOT] template class


Hello,

I am trying to write a template class. However I fail to generate
the dictionary:

-------------------------------------------------------------------

% rootcint -f TestClass_dict.C -c TestClass.h TestClass_linkdef.h

Error: Symbol int is not defined in current scope  FILE:TestClass.h LINE:286
*** Interpreter error recovered ***
Error: Symbol int is not defined in current scope  FILE:TestClass.h LINE:286
*** Interpreter error recovered ***

-------------------------------------------------------------------

Source files are listed:

*****************************************************
* File TestClass.h
*****************************************************

#ifndef __TestClass__
#define __TestClass__

#include "TObject.h"

template<class Type>
class TestClass : public TObject
{
public:

  TestClass();
  ~TestClass();

private:

  Type *_tree;


  ClassDefT(TestClass, Type)
};
ClassDefT2(TestClass, Type)
ClassImpT(TestClass, Type)


template<class Type>
TestClass<Type>::TestClass() // Constructor
{
  _tree = new Type;
}

template<class Type>
TestClass<Type>::~TestClass() // Destructor
{
  delete _tree;
}

#endif

*****************************************************
* File TestClass.C
*****************************************************

#include "TestClass.h"


*****************************************************
* File TestClass_linkdef.h
*****************************************************

#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class TestClass<int>+;

#endif

*****************************************************

I appreciate for your help,
 - Jedong



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET