Vectors!
-
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
-
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
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
-
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
You Champion! :-D
-
You Champion! :-D
:-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