Ok, I got the method vector to work but I cant make it globably available and still be dynamic. My tile array is for tbs game and the tile array needs to be global because it gets accessed in basically every function/class everywhere in the program, its the all important thing.
With the vector thing, I can create that in a function but then its scope is only limited to that single function. If I were to put it at the begining of my program and make it global, it only becomes globally available for that single file (for the life of me I could not figure out how to make globably available to all files I like can with everything else, it just wouldnt work with the externs with multiple files), and on top of that, if do the globally avaible thing with the externs then the array dimensions cant be variable and thus it does become dynamc so I am at a loss.
Possibility
Dynamic class array allocation
Hey, good news, when I initially tried null_pointer''s method, it was saying some kind of error about no default constructor when creating the array, but when working with the vectors and trying out shit for that, I turned off the constructor and created my own and now retrying null points it works. Its totally global with all files and totally dynamic!
Here is what I did.
Initially i had my tile class as so:
the TILE(float x, float y, float z) was giving me crap loads of problems, so I made a different function instead instead of using the constructor.
And then I declared
TILE **tile;
and
extern TILE **tile;
globaly and in one of my initialization classes I was able to do:
and this works pretty good, So thanks guys for all your help, I really appreciate it alot.
Possibility
Here is what I did.
Initially i had my tile class as so:
class TILE{ TILE (float x, float y, float z) virtual ~TILE();};
the TILE(float x, float y, float z) was giving me crap loads of problems, so I made a different function instead instead of using the constructor.
class TILE{ Set_TILE (float x, float y, float z); //Set_TILE instead of TILE virtual ~TILE();};
And then I declared
TILE **tile;
and
extern TILE **tile;
globaly and in one of my initialization classes I was able to do:
//create the array tile = new TILE*[x_dimension]; for (int i = 0; i < y_dimension; i++ ) tile = new TILE[y_dimension]; //initialize the array for (int x = 0; x < x_dimension; x++) for (int y = 0; y < y_dimension; y++) tile[x][y].Set_Tile(variable1, variable2, variable3);
and this works pretty good, So thanks guys for all your help, I really appreciate it alot.
Possibility
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement