TArray of Abstract class type

When I declare a TArray and ISomeInterface has protected constructor & destructor and thus cannot be instantiated, it gives me an error that it can’t access the destructor!

Am I suppose to go around that by doing TArray < TSharedRef< ISomeInterface > > ?

Any other options?

Why is this happening?

Thanks :slight_smile:

If you do

TArray<ISomeInterface> SomeInterfaces;

the TArray requires a copy and for an abstract class that is not possible. Instead you should reference your interfaces through pointers or similar!

TArray<ISomeInterface*> SomeInterfaces;

Yep, I wrote it in the question but it stripped my it from opening tags (xss protection probably)… it was one of my examples :slight_smile:

What if I need to clean the memory?


TArray array;

array.Add(new A());


DOSE clean up the A istance?