fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Block {
  5. int* number;
  6.  
  7. Block(){
  8. number = new int;
  9. }
  10.  
  11. Block(const Block &other) {
  12. number = new int;
  13. *number = *(other.number);
  14. }
  15.  
  16. ~Block() {
  17. if (number != nullptr) {
  18. delete number;
  19. }
  20. }
  21. };
  22.  
  23. void function(Block block) {
  24. cout << block.number << ": " << *(block.number) << endl;
  25. }
  26.  
  27. int main() {
  28. Block block;
  29. *(block.number) = 1;
  30. cout << block.number << ": " << *(block.number) << endl;
  31.  
  32. function(block);
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
0x81a6008: 1
0x81a6018: 1