Article 6R5BJ [SOLVED] puzzled by out of scope

[SOLVED] puzzled by out of scope

by
mostlyharmless
from LinuxQuestions.org on (#6R5BJ)
No doubt this C++ concept is so obvious that it is completely over my head, but here is the problem:
Code: for (int i=0; i<= nV; ++i){
vertices2[i]=vertices[i];
}is a snippet in the middle of a procedure. "vertices" and "vertices2" are actually global variables, as is nV, which is actually the length of both. The intent is to make a copy of the one vector into the other. This doesn't seem to be the same as:
Code:vertices2=vertices which to my Fortran brain makes absolutely no sense, but ok, I can accept that. What really brings me here today is that while the above snippet compiles and (seems) to do what I wanted, I decided to check on the values in each vector, so I tried inserting the equivalent of a Fortran print statement:
Code: for (int i=0; i<= nV; ++i){

std::cout << vertices[i] << std::endl;

vertices2[i]=vertices[i];
}
Now the compiler (latest gcc/g++ on Arch) primly informs me that "i" is undeclared and out of scope.Could someone please enlighten me, and perhaps, other than berating me for being so crude as to want to insert a "print" statement, tell me how to accomplish the stated goal?
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments