What is the meaning of the following?
inline const char * operator*(AnEnumClass aclassinstance) {
...
}
Is it a function call operator overloading of the '*' operator or of the '()' operator? What does it accomplish and what is it used for?
CodePudding user response:
It's an overload of the *
operator that is returning a const char *
.
CodePudding user response:
inline // function should be marked as inline.
const char * // function returns this
operator * // function is the multiplication operator
(AnEnumClass aClassInstance) // RHS argument to operator
The operator takes as LHS whatever the encapsulating class is.
You invoke it with:
const char * aString = aClass * aEnum;
(Given instances of the encapsulating class and the enumeration type.)
Both Wikipedia and cppreference.com have a whole page on operator precedence and argumentation that you should peruse.