I read that true C++ pure virtual functions are not supported in Unreal but that we can use the PURE_VIRTUAL macro instead. The interface documentation says that pure virtual functions are supported so I tried creating an interface and using the PURE_VIRTUAL macro:
Then I created a new Actor and made it also inherit from ITestInterface:
I didn't provide and implementation for Test() anywhere but it still compiles without giving me any kind of error or warning that I can see.
Where did I go wrong?
asked Feb 24 '18 at 08:46 PM in C++ Programming
From what I can tell, PURE_VIRTUAL is a way to detect when an interface function has not been overridden. It creates a stub function that will generate a warning at runtime (not compile time). It's more of a TODO marker than a modifier of a function declaration. Try running it.
answered Feb 24 '18 at 09:02 PM
Try to declare your pure virtual function like this:
Please note that extra ; if you are returning void. If you are returning other value type, just provide default value or any value really. You need to pay attention to implement that function in derived class otherwise you will get message like this: "Pure virtual not implemented". Typical usage for this macro is if you want to make pure abstract base class.
answered Jun 21 '19 at 08:26 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here