How is array being "copied" in C++ or Java -
basically, question how memory managed compiler.
double[] b = {1.0, 2.0, 3.0}; double[] = new double[3]; //for java double a[3]; //for c++ = b;
when array a
declared, 24 bytes memory space assigned array a
.
a=b
copies the value of reference of array b
a
.
what 24 bytes memory block? deallocated immediately, or reclaimed end of function/method?
when array declared, 24 bytes memory space assigned array a.
in c++. in java reference allocated on declaration, , array allocated in initializer.
a=b copies value of reference of array b a.
in java. in c++ isn't legal code.
what 24 bytes memory block? deallocated immediately, or reclaimed end of function/method?
in c++ disappears enclosing scope or more enclosing method. in java becomes eligible garbage collection when last reference disappears, in case end of method.
your question mixed make more sense out of that. try thinking in 1 language @ time.
Comments
Post a Comment