# Can I use a template class?

**URL:** <https://forums.unrealengine.com/t/can-i-use-a-template-class/373431>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 15, 2016, 9:04pm UTC](https://forums.unrealengine.com/t/can-i-use-a-template-class/373431 "2016-10-15T21:04:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GigasightMedia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GigasightMedia](https://forums.unrealengine.com/u/GigasightMedia)\
**Post date:** [October 16, 2016, 8:54pm UTC](https://forums.unrealengine.com/t/can-i-use-a-template-class/373431/2 "2016-10-16T20:54:50Z")

</div>

As far as I know, UObjects and AActors (and derived classes) do not support template classes. The UnrealHeaderTool attempts to resolve all symbols within the header, so you’re getting those errors.

Alternatively, you can create a UInterface and related IInterface:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

> **[Interfaces](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Interfaces/)**
>
> Reference to creating and implementing interfaces.

[https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UInterface/index.html](https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UInterface/index.html)

If you don’t like that, you can create your base class with the UCLASS specifier “Abstract”, and then include a noentry or unimplemented assertion within your methods. e.g.:

```
//header

#pragma once

#include "MyAbstractClass.generated.h"

UCLASS(Abstract)
class MYGAME_API UMyAbstractClass : public UObject
{

    GENERATED_BODY;

public:

    UMyAbstractClass();

    void MyMethod();

};

//source

#include "MyAbstractClass.h"

UMyAbstractClass::UMyAbstractClass()
    :
    UObject()
{}

UMyAbstractClass::MyMethod()
{
    unimplemented();
}

```

With that structure you’ll get an error thrown if any of the methods are called without being overridden. The “Abstract” specifier prevents the engine from allowing instances of the class to be created directly, but instances of derived classes remain legal.

[https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Classes/Specifiers/Abstract/index.html](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Classes/Specifiers/Abstract/index.html)

> **[Asserts](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/ProgrammingWithCPP/Assertions/)**
>
> Reference to Unreal Engine 4's Assert Functionality

Hope that helps.

---

_[View the full topic](https://forums.unrealengine.com/t/can-i-use-a-template-class/373431)._
