fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #define timefnrt(W, X, Z){\
  4. time_t V = time(NULL);\
  5. W = X;\
  6. time_t Y = time(NULL);\
  7. Z = difftime(Y, V);\
  8. };
  9. class foo {
  10. public:
  11. int somefunc(int& x, int y) {
  12. for (int i = 0; i < x; i++)
  13. printf("Iteration %d\n", i);
  14. printf("Address of x within func is %p\n", &x);
  15. printf("Address of y within func is %p\n", &y);
  16. printf("Address of object within func is %p\n", this);
  17. return y;
  18. }
  19. };
  20. int main() {
  21. foo f;
  22. double ftime;
  23. int retval;
  24. int x = 2;
  25. int y = 30;
  26. printf("Address of x in main is %p\n", &x);
  27. printf("Address of y in main is %p\n", &y);
  28. printf("Address of object in main is %p\n", &f);
  29. printf("---\n");
  30. timefnrt(retval, f.somefunc(x, y), ftime);
  31. printf("Return value was %d, Time taken was %f seconds\n", retval, ftime);
  32.  
  33. }
Success #stdin #stdout 0s 4252KB
stdin
Standard input is empty
stdout
Address of x in main is 0x7fff2702079c
Address of y in main is 0x7fff270207a0
Address of object in main is 0x7fff27020798
---
Iteration 0
Iteration 1
Address of x within func is 0x7fff2702079c
Address of y within func is 0x7fff270207a4
Address of object within func is 0x7fff27020798
Return value was 30, Time taken was 0.000000 seconds