473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What's the opposite of dynamic ?

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
4 4686
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ray Tomes | last post by:
Hi all Many thanks to those that answered my questions about whitespace and ord() being reverse of chr(). As well as the 2 things I asked about I learned about 5 other useful things. This I...
22
by: achrist | last post by:
The yield statement looks to be a big step toward some kind of lightweight concurrency-oriented programming in python. Is there any similarly nice way to do the opposite of yield, just sit around...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
9
by: gold | last post by:
Hello all, I want know abt wht kind of datastructures using both C & C++ internally. Some were said heap, others said tree anyone can explain brief?
7
by: Peter Morris | last post by:
What is the oposite of Object Oriented? C# is an object oriented language but C is a _______ language. -- _______________________ /_____________________(_) | _____________________ ...
16
by: Bob Hairgrove | last post by:
Consider the classic clone() function: class A { public: virtual ~A() {} virtual A* clone() const = 0; }; class B : public A { public:
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
123
by: plenty900 | last post by:
I was looking over someone's C++ code today and despite having written perfectly readable C++ code myself, the stuff I was looking at was worse than legalese. The people who are guiding the...
33
by: James H. Newman | last post by:
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.