Alf said:
* Victor Bazarov:
Do you know of a C++ implementation that where 'auto' is not equivalent
to stack-based, or where ordinary 'new' doesn't allocate from a heap?
Literally you're probably correct, I don't bother checking.
As a matter of practice it is, however, a meaningless distinction.
"Meaningless distinction" between what ant what? Between stack and heap?
In the language Standard the two places where you should find 'stack' and
'heap' are the library templates and functions (namely, 'std::stack' and
'std::make_heap'). There are no other places. Whether or not there exist
implementations that do something different is irrelevant.
BTW, on some operating systems I've encountered, "stack" was actually
allocated on the "heap" [at program loading]. Now, how you attach heap
(where "ordinary 'new'" allocates), to the OP's question, I am not sure.
And how do you answer the question about the literals in terms of stack
and heap I am not sure either because on some systems they can be on the
stack and on some they will be in a constant data segment (not stack or
heap at all). Also, the location of static data and what you call "heap"
(C++ uses the term "free store") are not necessarily the same either.
So, whatever they teach to those kids in the school the OP attends, has
nothing to do with the language itself and everything to do with their
specific implementation of the language on their specific platform. And
we cannot help the OP, he would have to look in the textbooks his teacher
recommended. The validity of those textbooks is beyond the limits of this
thread.
IMNSHO.
V