Definition of classes

0

When I studied about defining a class it would look like this in the header:

class Jogador {
    int id;
    std::string nome;
    int vida;

    void setNome();
    std::string getNome();
}

But I see a bit about unreal engine and I came across it in one of its codes:

class UspringArmComponent* CameraBoom;
class UCameraComponent* FollowCamera;

Does anyone help me to understand this definition?

    
asked by anonymous 17.04.2018 / 02:21

1 answer

3

When you are working with an Engine the first thing to look at is the documentation because there are important things to start with, such as:

  • tabs
  • examples
  • tutorials
  • Getting Started
  • explanation of certain components
  • available features

For Unreal Engine 4 you can refer to documentation here .

Regarding the two lines of code you indicated (be careful that s in Spring must be high):

class USpringArmComponent* CameraBoom;
class UCameraComponent* FollowCamera;

You are creating two fields in the class, which are two pointers. This would be similar to doing:

Jogador* jog;

That would create a pointer to the class Jogador called jog , but without the reserved word class . It was used to make the statement too, usually called the forward declaration. This way you can use the pointer even without having previously interpreted the definition of the class through its header.

To end the classes in question has the following meaning:

  • UCameraComponent - Represents a point of view of the camera, contemplating type of projection, angle of view and some configurations. This class is derived from USceneComponent .
  • USpringArmComponent - This component tries to keep your children at a fixed distance from the parents, but will collect the children if there is a collision and re-expand if there is none. It also derives from the USceneComponent class.

Documentation relevant to these classes:

17.04.2018 / 11:37