Archived

This topic is now archived and is closed to further replies.

a variably clarification question

This topic is 5870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, i think i understand it but i wanted to clear this up. I need a way to declare globals on the spot. If i declare a variably in my game_init() function, my game_loop() fuction cannot access it so I think i know how to solve it. So would i have to do something like the following?
  
int newints* = new int[10];
newintvar = 1;


//in the game_done() function

delete newints
  
could some1 please tell me if this is correct

Share this post


Link to post
Share on other sites
No, thats not what i meant. I meant something like creating a variable in a function that does not terminate when the function returns. I wanted it to be created in the game_init() function and deleted in the game_done() function.

Share this post


Link to post
Share on other sites
Is that what you want ?

    
int* newints; // at the top of the source file


.
.
.

void
game_init()
{
newints = new int[10];
}


void
game_loop()
{
newints[0] = 5;
newints[1] = 10;
}

void
game_done()
{
delete[] newints;
}



Edited by - Fruny on November 18, 2001 5:55:45 PM

Share this post


Link to post
Share on other sites