If you are a complete beginner I advice starting with blueprints, making very simple games without many complications to get accustomed to Unreal’s systems. Even if you mastered C++ there are still plenty of valid reasons to use blueprints. It is faster, not all code is performance-critical, and using blueprint classes makes managing references easier even if your code is mostly written in C++. Also, all the other editors will remain the same regardless of which program paradigm you use.
The reason you cannot find find the cube inside the world through GetDefaultSubobjectByName is because the cube is not a default subobject of the world. Default subobjects are created in the object constructor using CreateDefaultSubobject(Text(“ObjectName”)).
So while the actors are placed “in the world”, they aren’t defined as default subobjects of the world class. There are plenty of logical reasons why it can’t be so. One of the most obvious ones is that not every level will have the same object in it by default.
Another good clue is that while you can actors as components if used as child actor components, actors themselves aren’t components. Component classes inherit from UObject without inheriting from AActor and will have the U-prefix in the class name.
So, rather than thinking that the actor will be a component of the world once placed in the level, you should think the world as something that holds references to all the objects. Then different systems can do all their required work by iterating through them.
If you want to access the cube you have to get the reference somehow. For example, on spawn, your cube could pass a pointer of itself to the gamemode. You should also remember to remove the pointer if the cube is ever destroyed.
I made a quick example of how you could do this. Using my trigger boxes/spheres that are placed in the level in this case, but you could use any type of actor - added StaticMesh at the end for completeness. And in the C++ Actor base class, these get simply listed in BeginPlay() in that case:
LogTemp: Display: Have Trigger TriggerBox_nearing_chicken
LogTemp: Display: Have Trigger BoxTriggerGameWon
LogTemp: Display: Have Trigger TriggerBox-sign-reached
LogTemp: Display: Have Trigger TriggerSphere_reached_chicken
LogTemp: Display: Have Trigger TriggerSphere_BackWithChicken
So this way it can be done, but it is like GetAllActorsOfClass in blueprint - iterating everything - so not a good idea to do for example within tick.
EDIT: added the static mesh version to fit the question exactly: