fork download
  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. double* funct()
  8. {
  9.  
  10. double *mat;
  11. mat = new double[5];
  12.  
  13. mat[0] = 3;
  14. mat[1] = 6;
  15. mat[2] = 8;
  16. mat[3] = 12;
  17. mat[4] = 13;
  18.  
  19. cout << "in funct:" << endl;
  20.  
  21. for (int i=0; i<5 ; i++)
  22. cout << mat+i << " ";
  23.  
  24. cout << endl;
  25.  
  26. for (int i=0; i<5 ; i++)
  27. cout << *(mat+i) << " ";
  28.  
  29. return mat;
  30. }
  31.  
  32.  
  33.  
  34. int main()
  35. {
  36. double* mat_main;
  37.  
  38. mat_main = funct();
  39.  
  40. cout << endl << "in main:" << endl;
  41. for (int i=0; i<5 ; i++)
  42. cout << mat_main+i << " ";
  43.  
  44. cout << endl;
  45.  
  46. for (int i=0; i<5 ; i++)
  47. cout << *(mat_main+i) << " ";
  48.  
  49. system("pause");
  50. return 0;
  51. }
  52.  
  53.  
Success #stdin #stdout #stderr 0s 3028KB
stdin
Standard input is empty
stdout
in funct:
0x97db008 0x97db010 0x97db018 0x97db020 0x97db028 
3 6 8 12 13 
in main:
0x97db008 0x97db010 0x97db018 0x97db020 0x97db028 
3 6 8 12 13 
stderr
sh: pause: not found