Q1. Define the following words in terms of arrays\' lifetime (2 points) 1-1. sta
ID: 3590118 • Letter: Q
Question
Q1. Define the following words in terms of arrays' lifetime (2 points) 1-1. static array: 1-2. stack-dynamic array: 1-3. explicit heap dynamic array: 1-4. implicit heap-dynamic array re Q2. In formal definition, 'strongly typed' programming language refers to a language that type errors a always detected. It detects ALL misuses of variables that result in type errors (e g. error raised for a + b when a is an integer and b is a digit in char format) is C++ strongly typed language? Briefly describe your opinion. Q3. What are the two common problems with pointers?Explanation / Answer
Q1
1-1 Static arrays- Static arrays are allocated memory at compile time
and the memory is allocated in the stack
1.2 Stack dynamic array - Range and storage of this array is dynamic means
happens during execution but once done is fixed from then on till the
life time of the variable.
1-3 Explicit heap dynamic array -- This array gets allocted/deallocated from
the heap during run time with explicit instructions by the programmer in the program
1-4 Implicit heap dynamic array -- An implicit heap dynamic iten is bound to
heap storage when the variable is assigned the value.When a value is reassigned to the variable, allocation and deallocation happen implicitly.Lnguages like ALGOL 68 , LISP have such variables.
Q2
C++ do have strong type checking if any where type mismatch is there it
detects that and also provied a way of casting to explicity handle type
mismatches but there are occassions where implict type conversion
happens in c++ like if mathmatical expression is having float and integer
then all are upgraded to float.Bool types can be assigned numeric values.
So considering all thee C++ lies somewhere in between weak typed and strongly typed.
Q3
Two common problems witj pointers are :
1.Dangling pointers- pointer p1 is assigned space from heap. p2 is assigned p1. Then p1 gets deallocated so p2 becomes dangling.
2.Lost heap space:p1 is assigned a space in heap. Later it is assigned
some other space in heap. The first space got lost because it can not' be allocated.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.