Download presentation
Presentation is loading. Please wait.
Published byAlexandrea Applebee Modified over 10 years ago
1
Test 2 Jason Jenkins Lauren Sears Aaron Stricklin Brandon Wolfe Julie Alexander
3
C++ Review (2) Chapter 8 - 10
4
Enumeration Type user defined simple data type Data type - a set of values together with a set of operations on those values To define a new simple data type, called enumeration type, we need three things: – A name for the data type – A set of values for the data type – A set of operations on the values
5
Enumeration Type syntax for enumeration type value1, value2, … are identifiers called enumerators value1 < value2 < value3 <...
6
typedef Statement typedef does not create any new data types typedef creates an alias to an existing data type Typedef int myInt;
7
Namespaces When a header file, such as iostream, is included in a program Global identifiers in the header file also become global identifiers in the program If a global identifier in a program has the same name as one of the global identifiers in the header file The compiler will generate a syntax error (such as identifier redefined) The same problem can occur if a program uses third party libraries
8
namespace where a member is usually – a variable declaration, – a named constant, – a function, or – another namespace
9
String http://www.cplusplus.com/reference/string/string/
12
Structured Data Types -- Array A data type is called simple if variables of that type can store only one value at a time A structured data type is one in which each data item is a collection of other data items Array - a collection of a fixed number of components wherein all of the components have the same data type dataType arrayName[intExp]; dataType arrayName[intexp1][intexp2];
13
Array An array is a collection of a fixed number of components all of the same data type. Declaring: – dataType arrayName[intExp]; – int myArray[10] = {0}; – Int yourArray[] = {1,2,3}; Accessing: – arrayName[indexExp]; Write a function to find the max element in an array.
14
Multidimensional array dataType arrayName[][]…[]; Int matrix[NumOfRow][NumOfCol] Int matrix[NumOfRow][NumOfCol] = {0}; double matrix[2][2] = {{0.0,0.1}, {1.0,1.1}}; Accessing: – matrix[0][1]; Write a function to find the max element in each row of a matrix.
15
Array as parameters to Functions by reference only Functions can not return a value of the type array
16
Lab 1 Given a 10X5 matrix, transpose it to 5X10 matrix Input file: matrix.input Output file: matrix.output Write a function transposeMatrix to implement the transposition. Submit your code by 11:59pm Friday!
17
C++ reviews Chapter 11 – 12 Test 3: submit your test 3 in next class, only submit your answer sheet, please
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.