fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class Node
  6. {
  7. public:
  8. int val;
  9. Node(){val=0;};
  10. Node(int x){val = x;};
  11. };
  12.  
  13.  
  14. int main()
  15. {
  16. vector <Node*> nodelist;
  17.  
  18. for (int i = 0; i < 10; i++)
  19. {
  20. Node* temp = new Node();
  21. nodelist.push_back(temp);
  22. }
  23. nodelist[1]->val = 5;
  24. nodelist[6]->val = 3;
  25. nodelist[8]->val = 9;
  26.  
  27. for (int i = 0; i <10; i++)
  28. cout << nodelist[i]->val << endl;
  29.  
  30. return 0;
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
0
5
0
0
0
0
3
0
9
0