






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Typically stored contiguously
-^
Two-dimensional arrays:– Row major order: Rows stored contiguously– Column major order: Columns stored contiguously
-^
Row-major order more common– Allows two-dimensional arrays to be treated as “arrays of
arrays” (where each sub-array is stored together)
a[x] is stored contiguously)
Three basic models:– int a[10]: Size of array/addressing determined at compile-
time (“relatively static”)
run-time. Once determined, it cannot be changed. (“semi-dynamic”)
dynamically at run-time. Need operations to change size(a.add(), a.delete(), etc.) (“dynamic”)
Latter two models not available in C++
-^
Third model is available as a vector class
Strings could be implemented as arrays of characters.
-^
Problem: It is inconvenient to view them/treat them asstatically declared and allocated arrays.– String s;– s = “cat”;– s = “Now is the time for all good men”– How big is s? (could declare String s[50], but then you have to deal
with wasted space or arbitrary limits)
-^
Most languages simply treat them as fully dynamic arrays thatcan grow and shrink automatically– Space will typically be allocated from the heap
Suppose strings are implemented as pointers tosome string of characters in the heap.
-^
Two possible implementations of assignment (a = b):– Deep copy: Make a copy of the string referred to by b,
make a refer to the copy.
Shallow copy: Cheap, but results in aliasing (andpotential resulting problems)
-^
Deep copy: Expensive, but safer
Static vs. dynamic scope
-^
Separate compilation
-^
Namespaces and packages
-^
Static and dynamic linking
-^
Variable initialization
-^
Expression evaluation
-^
Conditional and iteration structures
-^
Parameter passing
-^
Data types:– Coercion/compatibility– Basic type implementation