When does a Parent Class Constructor get called?

In “Creating Child C++ Classes” we setup a child of BasePawn and declare and define the constructor. Coming from ios development, I’m used to manually calling the parent constructors, however we don’t do that here, and it appears to work fine.

Does unreal automatically call the parent constructor when in instantiates a Tank object? If so, how does it do that?

In c++ parent constructors get called automatically before constructors of the derived class if they do not take parameters. If it takes parameters, then I believe you need to call it manually from the derived class.

Here is an example: Compiler Explorer


This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms