another homework question...
Looking for an improvement to my code. It's a little much to post, but here's the idea:
I have a class --"savingsAccount"--
in the main function I declare three objects with savingsAccount.
I'd like to loop through some functions on my savingsAccount objects "dynamically". That is, if I do a
for (i = 0, i <= 3, i++)
it works fine, but what if I add 3 more objects? I don't want to go change the for loop everytime an object is declared. My approach has been to add a static count to the class that is increased each time an object is declared. I can then loop from 0 to "< savingsAccount::count". good? bad? ideas?
Second half of the same problem is getting the object names inside the loop. if I have:
what can be done inside the for loop so that a different object is chosen each loop, and so I don't have to go change the for loop code when a new object is declared? I'm thinking there is a pointer solution here somewhere, but the solution has evaded me so far...