I have created a series of instances of a struct inside a for loop. They all have names like object_0, object_1, and so on. Now during my render loop I need to access them all in another for loop, but can't figure out how.
To create them I used a function inside the struct which named it based on a name created by printing to a string ( sprintf( name, "object_%i", i ); ), also within the same loop. Now I need to access something inside each one on each pass ( object_0->Loc, object_1->Loc, etc. ).
How can I set a pointer to iterate over a series of instances with sequential names?
Thanks,
~KeithK
ps. I am new to this forum and a novice programmer. I am using C++ in Xcode with SIO2 Interactive game engine to make iPhone games. Check out my blog (which I have neglected to update for some time) if you want to check out my progress: keithkarnage.wordpress.com
Sounds like you should have used an array for them. To answer your question, there is no way to do that. You cannot access variable names, as C++ is not reflective, I believe it is called.
Wow thanks for the quick reply. I was just figuring out that I was doing things wrong any way, as my objects were not being properly instantiated. But an array would probably do the trick, I can't believe I didn't think of it. I'll let you guys know if I'm still having trouble sorting this out.
~KeithK