Jump to content
  • Advertisement

Archived

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

kmsixpence

a variably clarification question

This topic is 6149 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
Advertisement
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
How about something like this?
  
int* newInts;

void Game_Init(void)
{
newInts = new int[10];
...
}
...
void Game_Done(void)
{
delete[] newInts;
...
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!