A while back, we had this discussion already.
Found here
However, recently after reading through "Sam's c++ in 24 hours" by Jesse Liberty. I came up across this line: in a section on "arrays of pointers":
Quote:
|
The arrays discussed so far store all their members on the stack. Usually stack memory is severely limited, whereas heap memory is far larger. It is possible to declare each object on the heap and then to store only a pointer to the object in the array. This dramatically reduces the amount of stack memory used.
|
Later on in the paragraph right before the example "storing an array on the heap" it states:
Quote:
As an indication of the greater memory that this makes possible, the array is expanded from 5 to 500...
|
(Obviously an exaggeration "5 to 500")
I bolded the points that were a contrast to what you guys were saying.
Now saying that "Usually stack memory is severely limited, isn't BS is it?" For, many people have not mentioned that.
I'm completely confused now, you guys are saying one thing... the books telling me another thing. What's really going on and why has this author gotten away with being able to write (on the back of the book cover) "Over 250,000 readers have learned c++ from author Jesse Liberty".
/-------------------------------------------------
As Grumpy stated "is only",
Quote:
|
The distinction between the two forms, from a pure C++ perspective, is only to do with how lifetime of objects are managed.
|
Again Grumpy,
Quote:
|
From a C++ language perspective, the only purpose of new and delete are to manage dynamic memory. Nothing more, nothing less.
|
Dawei
Quote:
|
It has nothing, really, to do with memory architecture and what areas of memory are more "readily" available than others. The "stack" is, in reality, a lifo stack. Items are stored and retrieved in the expected way for lifo stacks.
|
Now, how is it that my book tends to go in a completely different direction of what you guys are saying. Now, I know there may be a good explanation for this. Please, someone clear this up.