What is the difference between static_cast and reinterpret_cast?

Viewed 56956

Possible Duplicate:
When should static_cast, dynamic_cast and reinterpret_cast be used?

I'm using c function in c++, where a structure passed as a void type argument in c is directly stored that same structure type.

eg in C.

void getdata(void *data){
    Testitem *ti=data;//Testitem is of struct type.
}

to do the same in c++ i use static_cast:

void foo::getdata(void *data){
    Testitem *ti = static_cast<Testitem*>(data);
}

and when i use reinterpret_cast it does the same job, casting the struct

when i use Testitem *it=(Testitem *)data;

this does the same thing too. But how is the structure gets affected by using the three of them.

1 Answers
Related