Review?
Ready to review?
Want more challenge? Lec01 Recap (CSE 022 Review in-depth)
Variables and Data Types
- char - single letter
char letter = 'w';- bool - true/false (in binary, 0 - false, 1 - true)
bool boolean = false;- int - whole numbers
int wholeNumber;- float - floating point with (high) precision by 7 decimal digits
float flo = 3.56f;
float flo2 = 3e5f;double- floating point with (low) precision by 15 decimal digits
double dob = 3.56;
double dob2 = 3e5;string- a bundled group of characters (chars)
string message = "Hello World!";Using cin and getline w/ cin ignore
- cin reads the input by converting the input into arguments, which are separated by the delimiter (whitespace)
- getline reads the entire line of the user input
- cin.ignore() is used to clear the memory buffer after cin is used
- It is important because cin leaves a buffer in the memory, which needs to be cleared before getline is called
If statement & Loops
See Statements and flow control
Vector
Member functions (size, push_back, pop_back, …)
- vector.size() - Returns the count of elements in vector
- vector.push_back(element) - Inserts the element at the last order of the vector
- vector.pop_back(element) - Removes the last element of the vector
- vector.at(index) - Returns the element that is in the order index
- Errors if the index is out of bounds
- vector[index] -Returns the element that is in the order index
- vector.clear() - clears all elements in the vector
Functions
See Functions
- Return Data Types
- No return with/without parameters
- Return without parameters
- Parameters pass by value or reference (
&) - Const for read-only parameters (not mentioned in the QuizFetch?)
dataType functionName(const string &msg) {
msg = "ok"; // throws an error because it's read only
}