CPP Array

Creator
Creator
Seonglae Cho
Created
Created
2023 Apr 25 7:16
Editor
Edited
Edited
2023 Apr 25 17:7

Constant Pointer

C++ will let you go beyond range
  • Unpredictable results
  • Compiler will not detect these errors
int children[3] = {2, 12, 1} int b[] = {5, 12, 11}; double n, a[10];
Fills rest with zero of array base type if fewer values than size supplied
Indexed variable handled same as simple variable of array base type
 

Standard Array is fixed size

 
 
 

3 pieces of array

because it is allocated back to back
  • Address of first indexed variable
  • Array base type
  • Size of array
So if length is 1, it is similar to
CPP Reference Type
 

Dynamic Array

Array type NOT allowed as return-type of function, so use * is legal
d = new double[10];
 
 
 
 
 

Recommendations