Four concepts:
- Encapsulation - setting access level for whatever is inside a class
- Abstraction - creating a design of things you like
Things learned today
- When you write static array and assign to a variable with less than x in array[x] then the rest of the space is by default filled in as 0 (in c++ 14)
- If you do not specify the length of the array, then the size is size of element multiplied by how many you put in when you initialize
- array as argument in a function parameter will 'read' only one element (int* aka pointer to int)
Top comments (1)
While the
sizeof
the array will only be ofint*
, all the 10int
s are still there pointed to by the pointer. In C++ (and C), the "pointer-ness" of the left-most array parameter is converted to a pointer.Neither C++ nor C actually has "array parameters" since they always decay into pointers. It's a hold-over from the New B language. While most of this is C-specific, the stuff about "array parameters" is true for C++ also.