fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. vector<int*> intPtrs1(10, nullptr);
  8. vector<int*> intPtrs2(10, nullptr);
  9.  
  10. for (auto intPtr : intPtrs1)
  11. intPtr = new int(1);
  12. for (auto &intPtr : intPtrs2)
  13. intPtr = new int(1);
  14.  
  15. for (int i = 0; i < 10; i++) {
  16. cout << intPtrs1[i] << " " << intPtrs2[i] << endl;
  17. }
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
0 0x97d5108
0 0x97d5118
0 0x97d5128
0 0x97d5138
0 0x97d5148
0 0x97d5158
0 0x97d5168
0 0x97d5178
0 0x97d5188
0 0x97d5198