Advertisement
Jambix64

VectorBeginEndUpdate3

Sep 4th, 2016
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  namespace variavel1{
  8.  int tm;
  9.  
  10. }
  11.  // Use scope resolution operator
  12.  namespace variavel2 {
  13.  
  14.      int receive1, receive2, receive3;
  15.  
  16.     }
  17. int main(){
  18.     using namespace variavel1;
  19.  
  20.     vector <int> v(3);
  21.     variavel2::receive1 = v[0] = 100;
  22.     variavel2::receive2 = v[1] = 200;
  23.     variavel2::receive3 = v[2] = 600;
  24.  
  25.     /*Para acessar o primeiro e o ultimo elemento do vector*/
  26.  
  27.     cout << *v.begin() << endl;
  28.     // Precisa decrementar
  29.     cout << *(--v.end()) << endl;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement