Advertisement
haykart

Untitled

Oct 13th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. void f(int∗ pi)
  2. {
  3.     void∗ pv = pi; // ok: implicit conversion of int* to void*
  4.     ∗pv; //error : can’t dereference void*
  5.     ++pv; //error : can’t increment void* (the size of the object pointed to is unknown)
  6.     int∗ pi2 = static_cast<int>(pv); //explicit conversion back to int*
  7.     double∗ pd1 = pv; // error
  8.     double∗ pd2 = pi; // error
  9.     double∗ pd3 = static_cast<double>(pv); // unsafe (§11.5.2)
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement