Guest User

Untitled

a guest
Nov 24th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. struct Foo {
  5. int n;
  6.  
  7. Foo(int nn) {
  8. n = nn;
  9. }
  10. };
  11.  
  12. int main() {
  13. Foo const *pfoo = new Foo(0);
  14.  
  15. std::cout << pfoo->n << std::endl;
  16.  
  17. Foo *ppfoo = (Foo*)pfoo;
  18.  
  19. ppfoo->n = 1;
  20.  
  21. std::cout << ppfoo->n << std::endl;
  22. }
Add Comment
Please, Sign In to add comment