CreateDefaultSubobject FName argument curiosity
How come the FName argument to CreateDefaultSubobject can accept a direct TEXT("") without having to wrap it in an FName() constructor? What is the C++ mechanism by which automatic conversion to an FName happens?
Hi, This is standard c++ stuff.
The constructor is called implicitly with a TEXT("") argument. You can have a look at NameTypes.h in the Engine and see the implementation of FName.
these two constructors:
Can be implicitly called (think about std::String, it can also be implicitly called passing a char* argument).
So, if the compiler type checking expects a FName and can call a implicit constructor it will do so.
In addition, you can forbid implicit constructor calling by flagging the constructor with "explicit" keyword, then you will have to call explictly the constructor.
answered Dec 07 '14 at 09:48 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here