fork download
  1. #include <iostream>
  2. #include <new>
  3.  
  4. class test
  5. {
  6. int i; // 4 bytes
  7. public:
  8. test() {std::cout << "ctor" << std::endl;}
  9. ~test() {std::cout << "dtor" << std::endl;}
  10.  
  11. void* operator new[](size_t n)
  12. {
  13. void* result;
  14.  
  15. result = ::operator new[](n);
  16. std::cout << "operator new[] size:" << n << " at:" << result << std::endl;
  17.  
  18. return result;
  19. }
  20. };
  21.  
  22. int main(int, char**)
  23. {
  24. test* p = new test[2];
  25.  
  26. std::cout << "new test[2] at:" << p << std::endl;
  27.  
  28. delete[] p;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
operator new[] size:12 at:0x8732008
ctor
ctor
new test[2] at:0x873200c
dtor
dtor