# PURE\_VIRTUAL method

**URL:** <https://forums.unrealengine.com/t/pure-virtual-method/291069>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 15, 2014, 6:00pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069 "2014-08-15T18:00:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sleicreider](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sleicreider](https://forums.unrealengine.com/u/Sleicreider)\
**Post date:** [August 15, 2014, 6:00pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/1 "2014-08-15T18:00:33Z")

</div>

AFAIK it’s only possible to create abstract methods using `PURE_VIRTUAL` instead of `virtual void MyMethod() = 0;`  
But does this `PURE_VIRTUAL` also work for non `UObject` classes? & classes without `UCLASS()` ?  
Until now it seems that it’s also possible that child classes don’t need to implement pure virtual methods with this macro.  
can anyone help?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1d769e01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1d769e01](https://forums.unrealengine.com/u/anonymous_user_1d769e01)\
**Post date:** [August 15, 2014, 6:10pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/2 "2014-08-15T18:10:24Z")

</div>

Hi Sleicreider,

You can use PURE\_VIRTUAL with non-UObjects, but there’s no reason to. I think the idea behind it was stub functions needed to exist for virtual methods so that “pure virtual” would work for BlueprintNativeEvent and other Blueprint-related virtuals.

The PURE\_VIRTUAL macro just inserts a runtime assertion that says you shouldn’t ever be executing that block of code, hence why child classes don’t need to override for it to compile, because C++ doesn’t recognize it as a pure virtual method.

It appears that the traditional C++ syntax is preferred in non-UObjects and the macro is actually _enforced_ in UObjects.

---

<div class="post-metadata">

**Author:** ![Sleicreider](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sleicreider](https://forums.unrealengine.com/u/Sleicreider)\
**Post date:** [August 15, 2014, 6:18pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/3 "2014-08-15T18:18:29Z")

</div>

but using c+ pire virtual functions(virtual void MyMethod() = 0); somehow doesn’t work at all in ue4 projects

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1d769e01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1d769e01](https://forums.unrealengine.com/u/anonymous_user_1d769e01)\
**Post date:** [August 16, 2014, 12:30am UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/4 "2014-08-16T00:30:49Z")

</div>

PrimitiveComponent.h line 36 says otherwise.

---

<div class="post-metadata">

**Author:** ![NoelWidmer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoelWidmer](https://forums.unrealengine.com/u/NoelWidmer)\
**Post date:** [August 23, 2016, 7:50pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/5 "2016-08-23T19:50:20Z")

</div>

Every UOBJECT must be isntaniciable in order for UE to create the CDO (Class Default Object) that is why UOBJECTs cannot be abstract. That just hit me hard… See [How do I implement Pure Virtual Methods? - Programming & Scripting - Unreal Engine Forums](https://answers.unrealengine.com/questions/28225/pure-virtual-methods.html)

---

<div class="post-metadata">

**Author:** ![Sleicreider](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sleicreider](https://forums.unrealengine.com/u/Sleicreider)\
**Post date:** [September 6, 2017, 9:14am UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/6 "2017-09-06T09:14:53Z")

</div>

oh .\_. good to know

---

<div class="post-metadata">

**Author:** ![bellicapax](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bellicapax](https://forums.unrealengine.com/u/bellicapax)\
**Post date:** [November 7, 2018, 8:06pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/7 "2018-11-07T20:06:17Z")

</div>

@thavik I don’t know what line/code you’re referring to, but that nowhere in that file could I find a pure virtual function.

---

<div class="post-metadata">

**Author:** ![Sleicreider](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sleicreider](https://forums.unrealengine.com/u/Sleicreider)\
**Post date:** [November 7, 2018, 11:29pm UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/8 "2018-11-07T23:29:17Z")

</div>

@bellicapax

He was refering to some older stages of the file from around version 4.4 where you could find `/** Defines a triangle by its vertices. */ virtual void DefineTriangle(const TStaticArray<FPrimitiveTriangleVertex,3>& InVertices,const UMaterialInterface* Material) = 0;` But seems like they changed some stuff in the file.

You can just check the old code on github if you linked your account.

---

<div class="post-metadata">

**Author:** ![bellicapax](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bellicapax](https://forums.unrealengine.com/u/bellicapax)\
**Post date:** [November 8, 2018, 12:05am UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/9 "2018-11-08T00:05:25Z")

</div>

My bad! Thanks for pointing this out. I should make better practice of checking when the answers/comments were left and taking in that context.

---

<div class="post-metadata">

**Author:** ![greg700000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@greg700000](https://forums.unrealengine.com/u/greg700000)\
**Post date:** [October 8, 2024, 6:14am UTC](https://forums.unrealengine.com/t/pure-virtual-method/291069/10 "2024-10-08T06:14:31Z")

</div>

I am unable to use pure virtual C++ in unreal (I get errors about instantiation). After falling eventually on this thread, I tried to use PURE\_VIRTUAL macro instead.

As mentioned by @@anonymous_user_1d769e01, using PURE\_VIRTUAL does not force overriding the method it only perform an assert in some situations.

That being said unless you find a way to use pure virtual cpp. I still recommend using PURE\_VIRTUAL for 2 reasons:  
-1: By seeing the PURE\_VIRTUAL macro in your .h you can then understand the intention behind the call.  
-2: If someone calls your PURE\_VIRTUAL method by accident, you can get ‘Pure virtual not implemented (AYourClass::YourPureVirtualMethod)’ in the crash reporter.

Still a solution that force the overriding of the method would be great.
