Test 2 Jason Jenkins Lauren Sears Aaron Stricklin Brandon Wolfe Julie Alexander
C++ Review (2) Chapter
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
Enumeration Type syntax for enumeration type value1, value2, … are identifiers called enumerators value1 < value2 < value3 <...
typedef Statement typedef does not create any new data types typedef creates an alias to an existing data type Typedef int myInt;
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
namespace where a member is usually – a variable declaration, – a named constant, – a function, or – another namespace
String
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];
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.
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.
Array as parameters to Functions by reference only Functions can not return a value of the type array
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!
C++ reviews Chapter 11 – 12 Test 3: submit your test 3 in next class, only submit your answer sheet, please