x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Closed] Interface as UPROPERTY, class member? [C++]

Hi!

To create an interface you must create two classes, one with the macro UINTERFACE which is deriving UInterface and one "normal" class that contains all the interface's pure virtual methods. Is this correct understood? source: https://answers.unrealengine.com/questions/4083/question-c-interfaces.html.

When I have created my interface it seems like it can't be used as a UPROPERTY and therefore not automatically added to the garbage collector. What type of pointer should one use to make a UINTERFACE a member of an other UCLASS such that it's managed by the garbage collector and references are increased and decreased properly? Is there some equivalent to std::unique_ptr from C++11 for unique objects? The UINTERFACE will only be implemented by classes that inherits UObject.

As a side note: I also tried to make an abstract UCLASS but seems like an UCLASS can't have pure virtual members even though it's created with UCLASS(Abstract). This seems a bit weird to me since having abstract/pure virtual methods is pretty much what makes an abstract class abstract except in some special cases. I get the following compilation error message:

error C2259: 'UGUIComponent' : cannot instantiate abstract class due to following members: 'void UGUIComponent::test(void)' : is abstract

where UGUIComponent is my class with the method virtual void test() = 0;

Product Version: Not Selected
Tags:
more ▼

asked Apr 08 '14 at 01:00 PM in C++ Programming

avatar image

undercover
843 123 111 138

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The question has been closed Jul 23 '14 at 12:51 PM by undercover for the following reason:

The question is answered, right answer was accepted


1 answer: sort voted first

Inherit Interfaces

You use multiple inheritance with interfaces, so for any class you want to implement an interface, you add the additional inheritance.

https://wiki.unrealengine.com/Interfaces_in_C%2B%2B#Multiple_Class_Inheritance

I have entire instructions and complete tutorial on interfaces here:

UE4 Interfaces Wiki

https://wiki.unrealengine.com/Interfaces_in_C%2B%2B

more ▼

answered Apr 08 '14 at 01:45 PM

avatar image

Rama
10.6k 446 343 1086

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question