fork download
  1. #include <iostream>
  2. class cla {
  3. int* data;
  4. public:
  5. cla(int input) {
  6. data = new int;
  7. *data = input;
  8. }
  9. ~cla() {
  10. delete data;
  11. }
  12. void copy(cla obj3) {
  13. *data = *(obj3.data);
  14. }
  15. };
  16. int main()
  17. {
  18. cla obj = {10};
  19. cla obj2 ={5};
  20. obj2.copy(obj);
  21. }
Runtime error #stdin #stdout #stderr 0s 4308KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
free(): double free detected in tcache 2