I'm trying to learn classes. I was originally using a struct for this.
Is there a way to incorporate my variable, "numbombs" without making it part of the object array? Or maybe a better way of going about this.
Make it part of the class, but declare it as a static variable. Then, memory for only one instance will be allocated, and all the objects will share it.
The way I have the code above is the way I want it to work only with "numbombs" within the class. Another words...I wouldn't want call it with an index number.
I'd like to call it with a class method like:
bomb.setNumbombs(30)
Not like:
bomb[index].setNumbombs(30)
I think a static variable only holds it's value out of scope. I just don't want to refer to it within an array.
I see how your doing that. I also didn't know I could initialize objects from within the constructor.
Can I initialize numbombs from within the constructor as well?