Quote
"It can go in any object of that class, since then every object would have a different copy of it. It can't be a local variable in main() or anywhere else, since objects might be created anywhere. The answer is to put that count in a static variable in the class. This variable belongs to the class, but one copy is shared by all objects, rather than each object having its own. Make sense?"
---------------------------------------------------------------------------
Sorry! Did not understand this...
("It can go in any object of that class, since then every object would have a different copy of it.) - diff copy of what? the object count? Did you mean it CAN go or it CANT go? If it CANT go, whats the problem if every object had its own copy of the count?
(It can't be a local variable in main() or anywhere else, since objects might be created anywhere. ) - dont get this either ... guess iam the greenest horn around.
(The answer is to put that count in a static variable in the class. This variable belongs to the class, but one copy is shared by all objects, rather than each object having its own. Make sense?") - Overall I was confused...I would be grateful if you could explain in detail...Thanks