Abstract type of variable

2

I have this line of code:

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

How does this return type work for me ( USphereComponent )? Is the variable going to save what kind of data type ( int , char , or some other default value)? And what size will it be?

    
asked by anonymous 26.06.2015 / 21:25

2 answers

4

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

In addition to the memory occupied by the pointer, there is also the memory consumption given by the size of the object instantiated in memory, which will depend on what is declared in the class (that is, 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 sizeof(USphereComponent) call. More details about sizeof on these SOEN questions:

Another good read is this article .

    
26.06.2015 / 21:47
4

You could have reported that you're messing with the engine of Unreal . Another thing, USphereComponent is not abstract . Technically speaking, it is considered concrete because you can instantiate objects of this type of data.

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

  

A pointer for an object of type USphereComponent .

USphereComponent is a data type offered by engine of Unreal, as well as char , int , float strong> primitive data types offered by the C / C ++ language.

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

To find out which variables and methods are encapsulated within double you should refer to Unreal Engine > API documentation. This is a fairly common practice when we are going to use an API we barely know: IDE to write source code positioned on one side of the screen, browser to view the other API's documentation.

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

    
26.06.2015 / 22:32