pabloliva87

Ej2C++

Mar 20th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string.h>
  4.  
  5. #define declare_at(type,name,address)                       \
  6.     type & name = *( get_mem ((type*)address) )
  7.  
  8. using namespace std;
  9.  
  10. template <typename TYPE>
  11. TYPE get_mem(TYPE address)
  12. {
  13.     TYPE result = address;
  14.     return result;
  15. }
  16.  
  17. int main (void)
  18. {
  19.     int initialized[1];
  20.  
  21.     declare_at (int, pepe, initialized);
  22.  
  23.     cout << "Value: " << pepe << endl;
  24.  
  25.     ++pepe;
  26.  
  27.     cout << "Value: " << pepe << endl;
  28.     cout << "AddressAlloced: " << initialized << endl;
  29.     cout << "AddressOfPepe: " << &pepe << endl;
  30.  
  31.     return EXIT_SUCCESS;
  32. }
Add Comment
Please, Sign In to add comment