"Bob Keith" <st*****************@yahoo.com> wrote...
I am studying some source code, on which I will do some further
development.
I couldn't understand the following code very well.
*****
stateset_result *r=(stateset_result*)p[1]->compute;
*****
I think the author use "cast" here, but I don't understand very well
of the concept of cast, and how to use them.
C++ has good and relatively solid rules for conversions from types
to other types. Casts are applied when such conversions don't work
or the compiler can't figure out which conversion to use.
There are three kinds of casts in C++. Explicit casts: static_cast,
const_cast, dynamic_cast, reinterpret_cast. Read about those in
your favourite C++ book. Function-style casts: type(variable). And
C-style casts (type)variable. The cast in the example you gave is
apparently C-style. The latter of three types of casts is the most
dangerous and least recommended. C++ code can be easily written
without C-style casts.
In the light of this, it is impossible to conclude anything from
the given fragment (one statement is really not enough), as to why
the cast is there and what it helps to accomplish. Perhaps if you
post more code...
Victor