Is it possible to create an Array of Classes?

The title pretty much says it all.
Essentially, I’ve got an Enum in my game that’s got names of 5 different classes. I want to be able to access the appropriate class based on which Enum value is selected and spawn an object of that class. Right now, the only way I know how to do it is through Branch checks, but I think Arrays would be more efficient.
However, I haven’t been able to find a way to create an Array of classes, so if anyone knows how to do that, I’d really appreciate the help. Thanks a lot.

you can use a map to do that. Use the enumeration as key and the class as value.

If you are replicating the array you have to take other solutions, because you can not replicate maps.

Yes, you can create an array of classes just like with any other variable type. You just need to make sure that all your 5 different classes can be derived from this particular class that you’re using as the variable type.

For example, if all of your classes can be placed in the level as actors, then you can set the Actor class as the variable type. It will then allow you to populate the array with any class derived from Actor.

Edit: But @Synia’s approach is more recommended. You can directly access each class with the enum without any additional logic.