Jump to content
  • Advertisement
Sign in to follow this  
Axiverse

Creating a temp array

This topic is 4912 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

you know how you can create a temp class that will automatically be destroyed when it goes out of scope? Can you do this with arrays?
class Foo
{
   Foo(int)

   Foo Blu() {return Foo(1)};
};

int main()
{
   Foo boo = Foo::Blu(); // <-- this var will be 
                //destroyed when this function ends
                //can you do the same thing with a char array?
                //or other array?

}


Share this post


Link to post
Share on other sites
Advertisement
Well you can create the array before using it, and free it after, but it won't be automatic.

Share this post


Link to post
Share on other sites
Only when the array is on the stack....

int func()
{
{
int temparray[100];
temparray[0] = 1;
}
temparray[0] = 0; // ERROR: temparray is out-of-scope
}


Or if you need it dynamically allocated, take a look at boost::array

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!