+ 4
The reinterpret_cast operator converts any pointer of a type to another pointer of a different type. Syntax : reinterpret_cast<final_type*> (&initial_object); Eg : ifstream fin; Class obj; fin.open("a.dat",ios::binary); fin.read(reinterpret_cast<char*>(&obj), sizeof(obj)); It is somewhat dangerous as it casts(forces) the type, and can convert a pointer of any type to a different type, even if the types have no relation at all. (Eg - unrelated classes). That is why there is no guarantee that the conversion would be successful or would work as expected and would not raise errors.
4th Feb 2018, 10:10 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar