fork download
  1. enum { SIZE = 10 };
  2.  
  3. struct Foo { /* some fields */ };
  4.  
  5. extern Foo global_array[SIZE]; // initialized elsewhere
  6.  
  7. struct Proxy
  8. {
  9. Foo* pointer_;
  10.  
  11. Proxy(Foo *pointer): pointer_(pointer) { }
  12. };
  13.  
  14. struct ProxyPOD
  15. {
  16. Foo* pointer_;
  17. };
  18.  
  19. Proxy get_first_element_as_pointee()
  20. {
  21. return &global_array[0];
  22. }
  23.  
  24. ProxyPOD get_first_element_as_pointee2()
  25. {
  26. ProxyPOD proxy = { &global_array[0] };
  27. return proxy;
  28. }
  29.  
  30. int main()
  31. {
  32. return 0;
  33. }
  34.  
  35. // else where:
  36.  
  37. Foo global_array[SIZE];
Success #stdin #stdout 0s 4172KB
stdin
Standard input is empty
stdout
Standard output is empty