Jump to content
  • Advertisement
Sign in to follow this  
Schinizer

static sized array question (c++)

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

Hi everyone,

I'm wondering, in a case like this:


class Node
{
public:
int array[255];
};


and I did this


Node* g_Node;
g_Node = new Node;


Where will the array be in? The heap, or the stack?

Share this post


Link to post
Share on other sites
Advertisement
The C++ standard says "the free store", which to you and me is "the heap", at least on Desktop systems.

Share this post


Link to post
Share on other sites
The C++ standard essentially says that memory allocated with 'new' comes from the "free store". It doesn't define what or where the "free store" is -- that's for each implementation to decide. I suspect that there's no one answer for embedded systems as a whole because they're so varied.

On your average desktop computer, C++ implementations are made such that "free store" is the same as "the heap" for all intents and purposes because that's what Joe Programmer reasonably expects.

This kind of language-lawyer dance is also true of automatic storage ("the stack"), incidentally.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!