fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct T {
  6. T (const char *s="") : a(s) { cout << "ctor : " << a << endl; }
  7. T (const T& rhs) : a(rhs.a) { cout << "ctor : " << a << endl; }
  8. ~T() { cout << "dtor : " << a << endl; }
  9. string a;
  10. };
  11.  
  12.  
  13. int main (void)
  14. {
  15. T kerker("kerker");
  16. T *p = (T *)operator new (sizeof(T) * 3);
  17. for (int i = 0; i < 3; i++) {
  18. *p = T(kerker);
  19. p++;
  20. }
  21. return 0;
  22. }
Runtime error #stdin #stdout 0.02s 2812KB
stdin
Standard input is empty
stdout
ctor : kerker
ctor : kerker