how do I use this method - with this array

I am trying to understand code for a for class assignment. It is the turtle with a pen exercise.


The .cpp file has:

int cmds[] = {5,5,4,5,9,2};
.
.
.other code here....
.
.
turtleOne.processTurtleMoves(cmds);




.h file has:

void processTurtleMoves(const int commands[])
{
return;
}


My question(s) are:

do the values from the cmds array, get passed to the processTurtleMoves method, and does this means I am able to do something with them? What ever I do with the values - example: loop through and multiply them by 2 - what is getting passed back to turtleOne.processTurtleMoves(cmds) and how do I access the new values.

I think this means I would have access to the turtleOne object in the main and be able to access these values - but I am not sure.


void processTurtleMoves(const int commands[])
{
return;
}


I believe when you declare as above, you should be able to read from commands all their elements but cannot attempt to change the value inside each element of commands.

Actually very easy to test out. You just write code inside processTurtleMoves attempting to read and write and see how the C++ compiler complains or not complains :P
Topic archived. No new replies allowed.