C ++ Local var in dynamics, on the stack?

Let's say that I have an object in dynamic memory (new) and inside one of its functions, it has

int Obj1::Add(int a, int b)
{
    int c = a + b;
    return c;
}

Is c (and a and b ...) on the stack? or in dynamic memory with my object. Just curious :) Thanks

+3
source share
5 answers

They will all be on the stack. aand the bparameters are passed, so even if the originals are on the heap, a copy will be made on the stack. If you followed the link, this may be another matter, since the thing actually sent ("under the hood") is more likely to be a pointer to the original.

For c, since this is a local variable, it is also on the stack.

, , . .

+3

"" "" ++. ++ " ":

++ ?

, a/b/c .

+3

. Sparc , , . 32- Intel ( 16 , ) a b.

. ( ): , this. , - , . , Intel, .. , .

+3

a, b c (, , ).

+1

. , c , .

0

All Articles