C++ Tanks vs Zombies 01: UProperty()...class? CreateDefaultSubject?
Hi, this tutorial series seems to be very nice! Looking forward to see more c++, although i'm already stuck in the first video of this series now :) There are two things I don't understand, and i don't wanna progress until i do understand these (propably) very basics:
The first looks normal to me - just a pointer to an UArrowComponent, but why is there a "class" tag on the second one? (I'm new to c++, guess it's basic c++ coding, but some explanation would be nice about that)
asked Jun 02 '17 at 07:23 AM in C++ Programming
The class keyword is used in this context to forward declare the type. In c++ it's used to avoid including the file holding that class. This helps a lot when you are in situations with circular dependencies where you have two classes that need variables to eachothers.
The CreateDefaultSubobject functions create default components for your class. If I recall correctly then it may only be used in constructors and not in any othe functions. If you want to create an object that's not an actor during runtime then
Is the way to go. Actors are a bit different as you need to spawn them in the world, thus need a reference to the world. An example is:
Then you can enter a multitude of params based on your needs.
answered Jun 02 '17 at 03:52 PM
class means forward declaration and it is often used to avoid compile dependency in header file. CreateDefaultSubobject is used to create objects in the class constructor.
answered Jun 02 '17 at 07:44 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here