Recently I came across this video on Programming Paradigms and the prof. used terms like Asterisks, Star, and Ampersand.
This was what how he used those operators:
int i = 37;
float f = *(float*)&i;
And how he voiced line 2 while writing it:
Float “f” equals asterisk float star, ampersand of i
I understand what asterisk and ampersand mean, but what is the significance of using star here? Is it synonymous to asterisk?
The
*after thefloatis used to form a type. Very often when referring to a pointer type in words people will say “star” after the type rather “pointer”, eg. “malloc returns a void star”. I’ve never heard anyone use “asterisk” to refer to a type.The
*at the start is used to de-reference the pointer thereby accessing the value it points to (interpreted as afloatdue to the following cast). Again, in my own experience I’ve never heard anyone use “asterisk” here. People just tend to say “de-reference” to describe the operation being performed.I wouldn’t read too much into it. There are two different contexts here as you rightly spotted and as long as you understand what they mean from a C++ point of view then that’s fine.