C++/CLI - What does the postfix operator '*' do?

103 views Asked by At

I am new to C++/CLI and I stumbled upon a strange notation. Are these syntaxes equivalent?

(ci*)->

and

(*ci)->

2

There are 2 answers

0
Dory Zidon On

Not to the best of my knowledge, most address related operators (&, *) should come before the variable, like in your case the *ci means what ci is point at, then the second pointer notation, what that is references.

(*ci)->

is the same as

**ci

however I do not think you can use a (ci*), post ++ or -- are valid, but I do not believe that you can do a *.

In general I'd avoid postfix operators as those create other problems (such as the value changes before and after the expression you're evaluating).

0
midor On

Usually the binary operator * is used for multiplication: a * b. Because operators can be defined by the user, it can mean pretty much anything, but uses that are completely different from the meaning of the original operator are discouraged. As for a unary postfix version of operator *, this is the first time I have seen or heard it, and to my knowledge this is not defined for built-in types.