# TQClass::New fails for templates

**URL:** <https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047>\
**Category:** ROOT\
**Created:** [November 7, 2026, 9:40pm UTC](https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047 "2026-11-07T21:40:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlalik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rlalik/32/25117_2.png) [@rlalik](https://root-forum.cern.ch/u/rlalik)\
**Post date:** [November 7, 2026, 9:40pm UTC](https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047/1 "2026-11-07T21:40:28Z")

</div>

I am working on event display for some project (FairRoot namely) and I want to modify a class `FairBoxSet` which derivates from `TEveBoxSet` to become a template (but I use it under name `FairShapeSet`), so from:

```cpp
class FairShapeSet : public TEveBoxSet { FairShapeSetDraw* fDraw{}; }

```

to

```cpp
template<class T>
class FairShapeSet : public TEveBoxSet { FairShapeSetDraw* fDraw{}; }
// pay attention that T is not used at all in the class body (it's MWE case)

```

There is another class `FairShapeSetDraw` which stories object (smart pointer) of `FairShapeSet<int>` and adds FreeBoxes into it. In the event display the boxes are then displayed. `FairShapeSetDraw` is abstract class (it has pure virtual method) and not used directly but is a base class for the final class, which displays boxes related to certain detector type.

When `FairShapeBox` is not a template, then everything works flawless, but when I change it to template, I have this error:

```auto
root [1] Error in <TQClass::New>: cannot create object of class FairShapeSet<int>
Warning in <TEveElement::PaintStandard >: IsA='FairShapeSet<int>'. Viewer3D requires more sections (48). Only direct-rendering supported.

```

In my code I replaced every use of `FairShapeSet` to `FairShapeSet<int>` and also in LinkDef there is appropriate change:

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

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

```

My first guess was that `FairShapeSet` needs to have default constructor, but not-templated class doesn’t have one and it works.

I’ve checked whether I can use the class manually:

```cpp
root [0] auto cl = TQClass::GetClass("CbmMustHitSetDraw")
(TClass *) 0x55795b70dc70
root [1] cl->New()
(void *) 0x55795d88bd70
root [2] auto cl = TQClass::GetClass("FairShapeSetDraw")
(TClass *) 0x55795b1ff2c0
root [3] cl->New()
input_line_44:5:21: error: allocating an object of abstract class type 'FairShapeSetDraw'

```

which makes sense for `FairShapeSetDraw` as it is an abstract class. But it is nowhere used in the code directly beside being a base class (and also as said above, it works in the `FairShapeSet` is not a template). `CbmMustHitSetDraw` is created without problem.

So I don’t understand why and when, the macro tries to create the set-related class, and why it works for non-templated but fails for templated version.

* * *

_ROOT Version:_ 6.36.00  
_Platform:_ Linux  
_Compiler:_ GCC-15

* * *

---

<div class="post-metadata">

**Author:** ![lbreitwi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lbreitwi/32/21330_2.png) [@lbreitwi](https://root-forum.cern.ch/u/lbreitwi)\
**Post date:** [November 8, 2026, 7:31pm UTC](https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047/2 "2026-11-08T19:31:02Z")

</div>

Hi @rlalik,  
Thank you for your post. Could you please send us a self-contained reproducer?

---

<div class="post-metadata">

**Author:** ![rlalik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rlalik/32/25117_2.png) [@rlalik](https://root-forum.cern.ch/u/rlalik)\
**Post date:** [November 8, 2026, 8:17pm UTC](https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047/3 "2026-11-08T20:17:38Z")

</div>

I wish to have one. I am using `FairRoot` + `CbmRoot` + several root files with geom, params, hits. And everything is happening somewhere inside TEve logic. Not sure if I can make it without actually providing all the frameworks.

I will see if I can prepare some MWE, but perhaps I need some days for that. If anyone has some ideas in the meantime, I appreciate.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 22, 2026, 8:18pm UTC](https://root-forum.cern.ch/t/tqclass-new-fails-for-templates/65047/4 "2026-11-22T20:18:34Z")

</div>

Closed on November 22, 2026, 8:18pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
