Advertisement
deadlinesarefun

incriment

Feb 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <cstdlib>
  9. #include <ctime>
  10. #include <string>
  11. using namespace std;
  12.  
  13. int main() {
  14.  
  15.     //didnt work as there was no pointer pointing to the value stored in the iterator.
  16.     vector<int>::iterator iter;
  17.     vector<int>scores;
  18.     scores.push_back(1);
  19.     scores.push_back(1);
  20.     scores.push_back(1);
  21.     scores.push_back(1);
  22.  
  23.     for (iter = scores.begin(); iter != scores.end(); ++iter)
  24.     {
  25.         *iter = *iter+=1;
  26.     }
  27.  
  28.     for (iter = scores.begin(); iter != scores.end(); ++iter)
  29.     {
  30.         cout << *iter << endl;
  31.     }
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement