Quote Originally Posted by lni View Post
Do some google search on "array in stack overflow", or at
http://www.devx.com/tips/Tip/14276
I can't see any connection between that article and things you are saying :P
As for me it's simple:

If there's code like this:
Qt Code:
  1. A a;
To copy to clipboard, switch view to plain text mode 
object a of type A is created on stack. If that code appears as a local variable in some function/method then at the end of the function/method object a will be deleted from stack, because program is returning to the caller, to place where call appeared.
(that's why there's stack overflow in infinite recursion -> infinite storing the called method variables and no returns, which will remove these variables from stack)

But if there's code like this:
Qt Code:
  1. A *a = new A;
To copy to clipboard, switch view to plain text mode 
instead of previously shown, then it's different story :] it means that your local variable created on a stack is a pointer (32-bit address = 4B) which points to the object of type A created on heap - not afecting stack in any way.

So if there is an array in struct created dynamically on a heap:
Qt Code:
  1. struct myStruc {
  2. QString myString;
  3. int *array;
  4. myStruc() {
  5. array = new int[ 3000*2000 ];
  6. }
  7.  
  8. };
To copy to clipboard, switch view to plain text mode 
then this struct size is just a size of myString and size of pointer to an array. An array itself is always on heap (beacause of operator new).


If there is any mistake in my understanding of stack/heap, feel free to provide any interesting links on this topic.