# Correct way to cast UInterface of Virtual functions? (NO UFUNCTIONS) C++

**URL:** <https://forums.unrealengine.com/t/correct-way-to-cast-uinterface-of-virtual-functions-no-ufunctions-c/1194492>\
**Category:** C++\
**Tags:** unreal-engine, question, CPP\
**Created:** [June 10, 2023, 1:59am UTC](https://forums.unrealengine.com/t/correct-way-to-cast-uinterface-of-virtual-functions-no-ufunctions-c/1194492 "2023-06-10T01:59:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [June 10, 2023, 3:12am UTC](https://forums.unrealengine.com/t/correct-way-to-cast-uinterface-of-virtual-functions-no-ufunctions-c/1194492/2 "2023-06-10T03:12:03Z")

</div>

Posts 5 and 7 might help you

> [@The real problem of blueprint CastTo](https://forums.unrealengine.com/t/the-real-problem-of-blueprint-castto/1185057/5):
>
> Curious, what did you benchmark there? In the editor with all other things running at the same time it’s hard to be accurate… maybe when testing a million runs I don’t know XD. There’s something else going on with interfaces, in c++ you have to do multiple checks to get a proper interface cast depending on if the interface is blueprint only or not. Extremely frustrating. bool bCanBeGrabbed = false; if (OtherOwner-\>Implements\<UGrabInteractionInterface\>()) { bCanBeGrabbed = IGrabInteractionInt…

Can’t tell you how this behaves with no UFUNCTION macro since it might not be able to reflect without one. Normally you declare your functions as UFUNCTION in the IMyInterface.

I believe that the only time you use

```auto
Implements<UGrabInteractionInterface>()

```

is when you need to test a blueprint implementation, but I might be wrong. If a method is not UFUNCTION it can’t be implemented by a blueprint.

Another way is to cast to it

```auto
else if (const IGrabInteractionInterface* OtherInterface = Cast<IGrabInteractionInterface>(OtherOwner)) {
	bCanBeGrabbed = OtherInterface->CanBeGrabbed(InPrimitiveComponent);
}

```

My post 5 on that link gives some info on when and why, but Chatouille in post 7 says things might be different in current versions of the engine.

---

_[View the full topic](https://forums.unrealengine.com/t/correct-way-to-cast-uinterface-of-virtual-functions-no-ufunctions-c/1194492)._
