fork download
  1. #include <stdio.h>
  2.  
  3. #define logh(x) printf(#x": 0x%08x\n",x)
  4.  
  5. typedef unsigned char byte;
  6.  
  7. class A {
  8. public:
  9. A();
  10. byte *getBufferAddress() { return buffer; };
  11. byte *getBuffer();
  12. private:
  13. byte *buffer;
  14. };
  15. A::A() {
  16. buffer = new byte[1024];
  17. }
  18. byte *A::getBuffer() {
  19. byte bs[1024];
  20. //copy(bs, buffer);
  21. logh(bs);
  22. return bs;
  23. }
  24.  
  25. int main() {
  26. A *a = new A();
  27.  
  28. logh(a->getBufferAddress());
  29. logh(a->getBuffer());
  30.  
  31. delete a;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
a->getBufferAddress(): 0x09ada018
bs: 0xbf80bae0
a->getBuffer(): 0xbf80bae0