endersdouble wrote:A. the C++ casts--const_cast,static_cast,dynamic_cast,reinterpret_cast. Huh? What's the deal? what are they, what's the difference between them and (type)expr casts?
They are more restricted versions of the general cast, and are intended to guard against programmer errors by forcing you to make your intentions more explicit. For example... const_cast
only allows you to remove or add the const
attribute; any attempt to change the underlying type is flagged as a compile-time error. I forget exactly what the other ones do, but the basic concept is similar, i.e. better compile-time checking.
I never use the new cast types myself... I just use the good ol' fashioned cast.
B. References. I know perfectly well how to use functions with pass by reference, and so on...but I had never heard of using references outside of function parameters. What are they, how does one declare one, when are they used?
I'd say that the second most common use of references is for return values of functions and operators. For example... the assignment operator always returns a reference to the left hand side of the assignment (the variable assigned to).
Declaring references "stand alone" is not particularly useful... if you do that, they are essentially just an alias for another variable.
The years just pass like trains. I wave, but they don't slow down.
-- Steven Wilson