Hello, I am working on a program for school and this is my first experience with arrays of objects. I am passing the array of objects into a function, and from within that function I am running another function that takes an individual object from the array as an arguemnt and then modifies some of its variables (the variables are public). It takes all of the arguemnts fine and no errors come up, however when I access the variables from within my main, they are not the modified versions that they are when accessed in my function. So overall my question is whether or not arrays of objects are passed by reference by default as most arrays are? Or if there is something I must do in order to solve my problem described above (note: I would like to avoid using global variables if possible)? Thanks and I can provide the relevant code if it is necessary.

~~Tofugames

EDIT: Well it turns out I just made a really dumb mistake and forgot to make one of the function arguments for the individual object a reference, and now everything is working fine! Also, how do I set the status of my topic to solved?

Arrays are passed by reference.
Your problem should be with the second function (not passing the single object by ref/ptr).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.