Access to indicator vector elements



  •   vector<int*> v;
      int p = 1;
      v.push_back(&p);
      //cout << что-то; //Здесь должно выводиться p(то есть, 1)
    


  • First, we need to get the element out of the body. For example,

    p[0];
    

    It'll be an index. int♪ Now you have to "small the star" - change the name.

    *p[0];
    

    Now you can get out.

    cout << *p[0];
    

    http://ideone.com/DkxqyT

    BACKGROUND

    You're putting an index on the variable that exists on the glass. If you keep the volume, and the variable is out of sight, you'll get it. Undetermined behaviour When applying to the index.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2