Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Vectors!

Vectors!

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael101
    wrote on last edited by
    #1

    Hey, I have a for loop iterating through a Vector. When my program hits certain conditions it needs to do get the value of an element and add one to it. I tried this but it didn't work: PrimeNumber(Iter + 1) += 1; It has to be the next element in the vector and it has to increment that next elements value by one! I've tried declaring an Iterator and using similar code -> *Iter + 1 += 1; but that still doesn't work :-( Does anyone have any ideas on how to modify the content of a vector? Thanks for all the help in advance I appreciate it! :) Michael

    N 1 Reply Last reply
    0
    • M Michael101

      Hey, I have a for loop iterating through a Vector. When my program hits certain conditions it needs to do get the value of an element and add one to it. I tried this but it didn't work: PrimeNumber(Iter + 1) += 1; It has to be the next element in the vector and it has to increment that next elements value by one! I've tried declaring an Iterator and using similar code -> *Iter + 1 += 1; but that still doesn't work :-( Does anyone have any ideas on how to modify the content of a vector? Thanks for all the help in advance I appreciate it! :) Michael

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      Michael101 wrote:

      using similar code -> *Iter + 1 += 1; but that still doesn't work

      *(Iter + 1) += 1;


      Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com

      M 1 Reply Last reply
      0
      • N Nibu babu thomas

        Michael101 wrote:

        using similar code -> *Iter + 1 += 1; but that still doesn't work

        *(Iter + 1) += 1;


        Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com

        M Offline
        M Offline
        Michael101
        wrote on last edited by
        #3

        You Champion! :-D

        N 1 Reply Last reply
        0
        • M Michael101

          You Champion! :-D

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          :-D Make sure you don't go beyond/access vector<>::end() when doing +1.


          Nibu thomas MVP For VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups