Abstract type of variable

Asked

Viewed 109 times

2

I have this line of code:

USphereComponent * SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));

How this kind of feedback works in my case (USphereComponent)? The variable will store what type of data (int , char, or some other default value)? And what size will it be?

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

2 answers

4

It will save a pointer to an object instance of the class USphereComponent. If you need to understand more about pointers, I suggest these other questions here from SOPT itself:

In addition to pointer-occupied memory, there is also the memory consumption given by the size of the instantiated object in memory, which will depend on what is declared in the class (i.e., what it contains - essentially its attributes with their respective sizes).

Even if the class is not of your implementation, it should be possible to estimate its size based on the call sizeof(USphereComponent). More details about the sizeof in these SOEN questions:

Another good read is that article.

4

You could have reported that you’re messing with the engine of Unreal. Something else, USphereComponent is not abstract. Technically speaking, she’s considered concrete because you can instantiate objects of this kind of data.

Well, the variable declaration USphereComponent * SphereComponent already indicates what she is:

A pointer for an object of the type USphereComponent.

USphereComponent is a data type offered by engine unreal, as well as char, int, float and double sane types of primitive data offered by the C/C language++.

In fact, new types of data (structs and classes) of the C/C++ language can be created from one or more variables of the primitive data types (which you already know).

To know which variables and methods are encapsulated within USphereComponent you should consult the API documentation (Application Programming Interface) of Unreal Engine. This is a fairly common practice when using an API we know little about: IDE to write source code positioned on one side of the screen, browser to view the API documentation on the other.

If none of this made any sense, start by investigating what is a pointer, afterward what is dynamic memory allocation, and finally, what are classes, to feel more comfortable programming in C++ and using other people’s Apis.

Browser other questions tagged

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