Class definition

Asked

Viewed 72 times

0

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

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

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

However I am seeing a little about Unreal engine and I came across this in one of her codes:

class UspringArmComponent* CameraBoom;
class UCameraComponent* FollowCamera;

Does anyone help me understand that definition?

  • Do not put code as image. Always put code as properly formatted text.

  • Thank you. I removed the image and put the code in question.

1 answer

3


When working with an Engine the first thing that matters is to see the documentation because it has important things to start, such as:

  • guides
  • examples
  • tutorials
  • first steps
  • explanation of certain components
  • features available

For Unreal Engine 4 you can refer to documentation here.

Regarding the two lines of code you indicated (be careful that the s in Spring it has to be higher):

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 as well, usually called forward declaration. This way you can use the pointer even without having previously interpreted the class definition through its header.

To finalize the classes concerned has the following meaning:

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

Documentation relevant to these classes:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.