C. Keywords, Commands, Variable Types, & Container Types Flashcards

1
Q

break

A
  1. When encountered inside of a loop, immediately stops the execution of the loop and jumps to the first statement following the loop.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

catch

A
  1. Designates the commands to be executed in response to an exception generated in a preceding “try” block.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

class

A
  1. Used to define a class. The general format is: class class_name {/* class description */};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

const

A
  1. Indicates that a variable will not change values; particularly useful for passing by const reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

continue

A
  1. When encountered inside of a loop, immediately stops the execution of that iteration of the loop and begins the next iteration (if any)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

delete

A
  1. Frees up dynamically allocated memory that was previously allocated with new
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

else

A
  1. Designates the commands to follow if an if condition evaluates to false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

extern

A
  1. Indicates that the definition for a function or class will be provided outside of the current file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

for

A
  1. Loop designator that provides a compact way of specifying all loop control in one place. The keyword is followed by parentheses containing 3 clauses sparated by semicolons: an initialization clause executed before the first iteration, a conditional to check at the beginning of each possible iteration, and an update clause to indicate what should change with each iteration. Alternatively, the parentheses can contain variable and container to iterate over, separated by a colon; the variable will take on each value from the container.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

friend

A
  1. Designates that a function defined outside a class should have access to a class’s members as though it were part of the class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

if

A
  1. Identifies the start of a condition. The keyword is followed by parentheses containing a Boolean (the condition), and following that are any commands to execute if the condition is true and, optionally, an else clause.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

namespace

A
  1. Designates a namespace to be used when creating classes or functions or, when coupled with using, when referring to a class or function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

new

A
  1. Allocates new memory dynamically (on the heap)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

operator

A
  1. Used to designate an operator that will be overloaded
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

private

A
  1. Indicates that subsequent class variables and functions should be private (accessible within that class only)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

protected

A
  1. Indicates that subsequent class member variables and functions should be protected (accessible to a class and its derived classes only)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

public

A
  1. Indicates that subsequent class member variables and functions should be public (accessible to anything)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

return

A
  1. Specifies the value to return from a function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

static

A
  1. Indicates a varable that should persist across multiple calls to a function. Static variables will maintain their value from the previous call to a function on subsequent calls rather than allocating a new local variable with each function call
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

struct

A
  1. An alternative to a class. Traditionally used only for grouping member variables, it now provides the same functionality as a class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

try

A
  1. Designates a section of code that should be executed but that might generate exceptions. Exceptions are handled by code in a subsequent catch block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

typedef

A
  1. Defines a new name to be used for a type; allows a user to use more compact and meaningful type names.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

using

A
  1. Indicates a namespace to be used by default so that namespaces do not need to be specified explicitly for every command.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

virtual

A
  1. Indicates that a function in a class can be defined more specifically in derived (children) classes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

void

A
  1. A type indicating no information; commonly used to specify the return type for functions that do not need to return a value
26
Q

void

A
  1. A type indicating no information; commonly used to specify the return type for functions that do not need to return a value
27
Q

while

A
  1. Loop designator. The keyword is followed by a conditional in parentheses and then by commands to be executed repeatedly, as long as the conditional evaluates to true at the beginning of the loop
28
Q

begin

A
  1. A member function of a container returning an iterator pointing to the first element in a container. Calling .begin() on the container will return the iterator
29
Q

cin

A
  1. A source (obtained by using #include<iostream>) for streaming console input (input typed in by the user)</iostream>
30
Q

cout

A
  1. A destination (obtained by using #include<iostream>) for streaming console output (output to be printed in the console window)</iostream>
31
Q

end

A
  1. A member function of a container returning an iterator pointing to the position just after the last element of a container. Calling .end() will return the iterator. Typically, you use this by incrementing the iterator until it equals .end(), indicating that you have reached the end of the container.
32
Q

eof

A
  1. Member function for finding whether you have encountered the end of a file. Only when you have tried to read something past the end of the file will .eof() return true
33
Q

failbit

A
  1. A particular exception that is thrown when a file is opened incorrectly
34
Q

find

A
  1. An algorithm (obtained by using #include<algorithm>) for performing a linear search through a container (such as an array or a vector). It takes in a beginning and ending iterator and an element value to look for. It returns an iterator to the first position where a matching element is found or the ending iterator if nothing is found. Likewise, there is a .find() member function of the string class for finding a substring within a string (the substring is the only parameter, returning string::npos if nothing is found)</algorithm>
35
Q

getline

A
  1. A function that takes 2 parameters: an input stream and a string variable. A line (until an end-of-line character, such as new line: \n) is read in from the input stream and stored in the string variable.
36
Q

lower_bound

A
  1. An algorithm (obtained by using #include<algorithm>) for performing a binary search on a sorted array or vector. It takes in a beginning and ending iterator and an element value to look for. It returns an iterator to the first item that is greater than or equal to the item being searched for.</algorithm>
37
Q

sort

A
  1. An algorithm (obtained by using #include<algorithm>) for sorting vectors, arrays, or other containers. It takes in a beginning and ending iterator and sorts the elements from the beginning one to just before the ending one.</algorithm>
38
Q

string::npos

A
  1. A value used to compare to in order to find the end of a string. When searching in a string, if an item being searched for is not found, the location will be reported as string::npos, indicating that it was not within the string.
39
Q

auto

A
  1. Automatically determines the data type for the variable based on how the variable is first assigned a value. This is useful for avoiding long type descriptions when the type of the variable will be obvious, but in most cases, it is better to explicitly declare individual types. C++ keyword
40
Q

bool

A
  1. Boolean. The value 0 is false; any other number is interpreted as true. C++ keyword
41
Q

char

A
  1. A single character. Can also be interpreted as a very small integer. Pronounced “char” or “care.” C++ keyword
42
Q

double

A
  1. Floating-point decimal number that has double the precision of the float. C++ keyword
43
Q

float

A
  1. Floating-point decimal number that has double the precision of the float. C++ keyword
44
Q

fstream

A
  1. A file stream, used for reading from or writing files. Must #include<fstream></fstream>
45
Q

int

A
  1. Integer. Any non-decimal number over the range … -2, -1, 0, 1, 2 … . C++ keyword
46
Q

long or long long

A
  1. Integer using more precision and thus capable of representing larger numbers than standard int. C++ keyword
47
Q

string

A
  1. A sequence of characters strung together. Must #include<string></string>
48
Q

stringstream

A
  1. A string stream, used for reading from a string or writing to a string, similar to how you read and write to the console or to files. Must #include<sstream></sstream>
49
Q

void

A
  1. A null data type, usually used to indicate that a function has no return value or as a way of describing a generic pointer, where the type of the data stored in memory is not known. C++ keyword
50
Q

deque<type></type>

A
  1. Doubly ended queue. Can easily add to or remove from beginning or end. Must #include<deque></deque>
51
Q

forward_list<type></type>

A
  1. Stores data in a (singly linked) list. Compared to a list, it is somewhat more efficient for most operations, but it is highly inefficient to access the end of the list or to go backward through the list. Must #include<forward_list></forward_list>
52
Q

list<type></type>

A
  1. Stores data in a (doubly linked) list. Easy to add or delete at any point in the list, but no indexing is supported. Must #include<list></list>
53
Q

map<type1, type2>

A
  1. Stores key-value data pairs. The first is the key and is used as a unique index for storing data; the second type is the value that is associated with each particular key. Must #include<map>
54
Q

pair<type1, type2>

A
  1. Stores pairs of 2 data elements. Provides a simple way of grouping 2 data values of different types without creating a new class. Can #include<utility>, but this is automatically included in most other STL libraries, too.</utility>
55
Q

priority_queue<type></type>

A
  1. Allows data to be inserted and the largest element to be pulled out. The type is often a pair or other user-defined class. Must #include<queue></queue>
56
Q

queue<type></type>

A
  1. Supports adding elements and pulling out elements in the order they were added. Must #include<queue></queue>
57
Q

stack<type></type>

A
  1. Supports adding elements and pulling out the most recently added element. Must #include<stack></stack>
58
Q

tuple<type1, type2, …, typeN>

A
  1. Stores data in a tuple, allowing a simple structure for combining an arbitrary number of data elements of possibly different types in a single structure without creating a new class. Must #include<tuple></tuple>
59
Q

unordered_map<type1, type2>

A
  1. A version of the map that does not keep the elements in any particular order. More efficient than the map for operations but cannot give an ordered list of all elements. Must #include<unordered_map></unordered_map>
60
Q

vector<type></type>

A
  1. Stores data in a sequence that can be directly indexed and can be added on to at the end. Must #include<vector></vector>