Thank for that johhnyfreak,
That's interesting, even though you have instantiated 2 foo objects there is effectively only one 'bar' variable thanks to it being set global.
In terms of interest for myself - I'm assuming that the last one instantiated becomes the only version held in memory? But what is actually happening behind the scenes? Is it a case of one version being 'overwritten' or something else?
In some of the game programming books I've read (ages ago) for C/C++ they recommended using a lot of global variables and then using functions to change/access them directly rather than passing by value/reference to a function - due to impacts of pushing/removing from the stack... is this still considered good practice? Or has processor speed and available memory (especially with BlitzMax 2D programming) rendered the need for using this 'dangerous' practice unnecessary?
That's interesting, even though you have instantiated 2 foo objects there is effectively only one 'bar' variable thanks to it being set global.
In terms of interest for myself - I'm assuming that the last one instantiated becomes the only version held in memory? But what is actually happening behind the scenes? Is it a case of one version being 'overwritten' or something else?
In some of the game programming books I've read (ages ago) for C/C++ they recommended using a lot of global variables and then using functions to change/access them directly rather than passing by value/reference to a function - due to impacts of pushing/removing from the stack... is this still considered good practice? Or has processor speed and available memory (especially with BlitzMax 2D programming) rendered the need for using this 'dangerous' practice unnecessary?