Arrays
- C++ Arrays
- Used for a collection of objects of like type
- Declaration syntax: BaseType ArrayName[SizeExpr] =
{Initialization};
- Examples
- int A[10];
- char letters[15];
- float nums[5] = {3.0, 2.0, 4.55, 6.77, 0.332};
- Scope and Initialization (arrayinit.cpp)
- Initialization is optional, if not initialized then garbage values in
array
- Rules on initialization:
- Global scope: Automatically initialized to zero (or
equivalent)
- Local scope: Not automatically initialized
- Partial initialization
- Full initialization
- Implicit size
- Search for smallest (find_smallest.cpp)
- Demostrate program
- Modify program to find position