Asterisk as Overloaded Operator

In the lecture, Mikey mentioned that the asterisk before *Objectname is an overloaded operator. I searched about this term on Google but couldn’t find a satisfying explanation. Also in the following quiz, there is question to it but didn’t use “overloaded” to explain it. I thought this asterisk is just dereferencing like dereferencing a char pointer.


(upload://yOxiaDHRteIqKFbxSWF7NdoE92M.png)

Overloaded is just when you take a method or in this case an operator and replace its default behaviour. In the case of FString, the * is replaced with what would normally make you think of a pointer to return the content of the FString as a TCHAR array, and as it happens, a pointer to this array.

This website will show you how to overload and also some examples. It’s a bit more of a reference but the examples should help.

It’s not something you do often but if you wanted to create maths classes for example that supported basic arithmetic operators, you can override them using this technique.

operator overloading - cppreference.com

Please can you also remove the image of the question above. We ask students to not post the quizzes in the forum.

1 Like

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

Privacy & Terms