By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

What's the opposite of dynamic ?

P: n/a
Ok,
pX = new Stuff N];

Is dynamically created.

what about
Stuff x [N]; ?
To me saying it's statically allocated is wrong, because that goes to
static variables.
I can't call it stack allocation because it may be in a class, which
gets dynamically allocated.

Mar 20 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Mar 20, 2:00 pm, "dominic.con...@gmail.com"
<dominic.con...@gmail.comwrote:
Ok,
pX = new Stuff N];

Is dynamically created.

what about
Stuff x [N]; ?
To me saying it's statically allocated is wrong, because that goes to
static variables.
I can't call it stack allocation because it may be in a class, which
gets dynamically allocated.
Automatic allocation?

http://www.gnu.org/software/libc/man...ion-and-C.html

Mar 20 '07 #2

P: n/a
On 20 Mar, 18:00, "dominic.con...@gmail.com"
<dominic.con...@gmail.comwrote:
Ok,
pX = new Stuff N];

Is dynamically created.

what about
Stuff x [N]; ?
To me saying it's statically allocated is wrong, because that goes to
static variables.
I can't call it stack allocation because it may be in a class, which
gets dynamically allocated.
C++ defines three kinds of storage duration:

Dynamic storage duration for dynamically allocated objects like in
your first example that exist until explicitly deleted.
Static storage duration for objects like globals and those declared
static which exist from their point of definition until the end pf the
program.
And the third is called automatic storage duration - for things that
are automatically destroyed at the end of the scope in which they were
defined - i.e. local variables.

Member objects have the same storage duration as of the object of
which they are part.

Gavin Deane

Mar 20 '07 #3

P: n/a
On 2007-03-20 19:00, do************@gmail.com wrote:
Ok,
pX = new Stuff N];

Is dynamically created.

what about
Stuff x [N]; ?
To me saying it's statically allocated is wrong, because that goes to
static variables.
I can't call it stack allocation because it may be in a class, which
gets dynamically allocated.
You seem to be confusing C++ with Java, where all instances of classes
are allocated on the heap (or whatever they call it) and only builtin
typed (and references) are on the stack. In C++ things are where you put
them, consider the following:

class Foo
{
// ...
};

int main()
{
Foo a[5];
}

Here we declare an array of 5 Foo-objects all on the stack.

--
Erik Wikström
Mar 20 '07 #4

P: n/a
do************@gmail.com wrote:
Ok,
pX = new Stuff N];

Is dynamically created.
OK.
what about
Stuff x [N]; ?
Firstly, it is important to keep in mind that the notion of being "created"
(they way you use it) applies only to object _definitions_ or dynamic allocations.

Secondly, the answer depends on the context. If you write the above as a
_definition_ in local scope, then it has automatic storage duration, i.e. you
can call it "automatically created". In namespace scope it would have static
storage duration, i.e. it is "statically created".
I can't call it stack allocation because it may be in a class, which
gets dynamically allocated.
That's a completely and significantly different situation. If the above is
written in a class definition, then it is a _declaration_ of a class member
that, which is _not_ _a_ _definition_. The notion of being "created" does not
apply in this case at all. It is not created yet, neither dynamically nor in any
other fashion.

--
Bets regards,
Andrey Tarasevich
Mar 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.