cs31 lecture 17

Namespaces x the size of an array is set at its

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: an expression can be changed In explicitly explicitly x This is very useful to avoid confusion / when unsure about This which promotion will occur which x Syntax: (<type>)
[expression] Example: float x = (float)
(2 / 3)
 97 Arrays x Arrays are a collection of data elements organized in a Arrays specific order specific Roughly: a set of variables of the same type that can be accessed Roughly: in an homogeneous way in x Arrays are the core data structure to program useful things Matrices, images Data structures (stack, queue, graph, tree, etc.)
 can be Data programmed using arrays programmed 98 One-dimensional arrays in C++ x Syntax to declare an array: <type> <name>[<size>] Example: iint array1[10]; nt char mystring[256]; char x Syntax to pass a 1-d array allocated as above as argument Syntax to a function: to <type> <name>[[<size>]] Example: void foo(int array[10], char array2)
; 99 Some observations on arrays x Arrays are always pass-by-reference x Be careful: an array has the same liveness as a variable E.g., if declared within a function, the array...
View Full Document

This note was uploaded on 04/03/2014 for the course CS 31 taught by Professor Melkanoff during the Fall '00 term at UCLA.

Ask a homework question - tutors are online