Dereferencing Strings

Hello there, so in the beginning of the courses you told us to use the * before HiddenWord, which I did but I did not understand the pointer stuff of it. Now we use it again, which is fine, but unlike the rest of what you explain to me I have no idea what, why, when this works. I miss the whole explanation of this and it is bothering me a lot since I had such a problem before and I am doing this course but my way so I make something more unique but I find this essential in understanding.

Does my answer here help at all?

I guess so, so I short because we use a combination of C and Unreal stuff the variable needs to be converted so it will be understood, the * makes sure of it. If we used it another way it did not had to be done but in this case the code just doesn’t know the content of the variable, so we use a dereference converter basically to extract that information out of it? Sounds like a crappy explanation, but hope you understand, is this correct?

Unreal is using C and uses it in its API.

Basically, yes. A very oversimplified version is that FString looks a little something like this

class FString
{
public:
    const TCHAR* operator*() const 
    {
        if (IsEmpty())
        {
            return TEXT("");        
        }
        return Data;
    }
    bool IsEmpty() const { return Size == 0; }
private:
    TCHAR* Data;
    int32 Size;
};

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms