cs31 lecture 17

A class with methods and attributes the character at

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: f needed In to other functions (as a regular variable)
 to 103 Summary on arrays x Statically allocated arrays (eg, int a[10])
 CANNOT be Statically changed after the declaration (increase/decrease size)
 changed x Dynamically allocated arrays (eg, with malloc()
 CAN be Dynamically changed after the declaration, BUT needs to be freed changed x In all cases, you CANNOT know the size of an array apart In from where it is declared/allocated from 104 Multi-dimensional static arrays in C++ x Syntax to declare an array: <type> <name>[<size1>][<size2>]… Example: iint array1[10][20]; nt char mystring[256][2][42]; char x Syntax to pass an array allocated as above as argument to Syntax a function: function: <type> <name>[<size1>][<size2>] Example: void foo(int array[10][20], char array2[256][2][42])
; 105 Strings x C string: a 1-dimensional array of characters Example: char mystring[256]; x C++ string: an object storing 1-dimensional array of C++ characters characters E...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online