fork download
  1. #include <iostream>
  2.  
  3. struct Node
  4. {
  5. int value;
  6. void* p;
  7. Node(int _value)
  8. : value(_value), p(nullptr)
  9. {
  10.  
  11. }
  12. };
  13.  
  14. int main()
  15. {
  16. Node* list = new Node(5);
  17.  
  18. list->p = (void*) new Node(6);
  19.  
  20. // It is necessary to make check!
  21.  
  22. std::cout << list->value << " " << ((Node*)list->p)->value << std::endl;
  23.  
  24. // Need delete!
  25.  
  26. }
  27.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
5 6