C++ standard library Flashcards

1
Q

code written to be used as part of other programs

A

library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

libraries give you access to ready made blank

A

libraries give access to
functions
data
values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Function example

A

getline( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Data type example

A

vector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Value example

A

M_PI and M_e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
#include iostream
#include vector
these are blank
A
libraries
#include iostream
#include vector
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

vector
map
array
these are blank

A

data types
vector
map
array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Features of C++ Standard Libraries include

blank and blank facilities

A

Input and output facilities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Features of C++ Standard libraries includes
blank and blank facilities
container blank blank
blank functions
implementation of useful blank
the blank data type
and more...
A
Features of C++ Standard Libraries include
input and output facilities
container data type 
mathematical functions
implementation of useful algorithms
the string data type
and more...
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
#include vector
#include map
these are called blank
A

libraries but

these are container data types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

to use the features of C++ Standard library, you must #include the appropriate

A

header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Examples of headers

A
#include iostream
#include string
#include vector
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
#include cmath
#include cctype
#include cstring
#include cstdint
#include climits
these are all from
A

the older C standard library

yet still can be used by C++

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

char variable = ‘a’
char string = to upper(variable);
what would the output be

A

A
note that char is the data type
‘variable’ is the variable
toupper() uppercases what is in parentheses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
#include cmath
has advanced math functions such as 
pow(blank, blank)
which returns blank raised to the power blank
A

pow(base, exponent)

which returns base raised to the power exponent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
#include cmath
also includes 
sqrt(x): returns the blank 
log(x): returns the natural base-e logarithm of blank
log10(x): returns the base-10 logarithm of x
abs(x): returns the blank
sin(x), cos(x), tan(x): trigonometric functions
A

sqrt(x): returns the square root of x
log(x): returns the natural base-e logarithm of x
log10(x): returns the base-10 logarithm of x
abs(x): returns the absolute value
sin(x), cos(x), tan(x): trigonometric functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
#include cmath
predefined values such a
M_blank:
A

M_PI: Archimedes’ constant
M_E: Euler’s number
M_SQRT2: square root of 2

18
Q
#include cctype
contains functions for working with blank values
A
#include cctype
contains functions for working with char values
19
Q
#include cctype
contains functions for working with char values
isalnum(c): returns whether the character is alphanumeric 
isalpha(c): returns whether c is alphabetic
isdigit(c): returns whether c is numeric
islower(c): returns whether c is lower
isupper(c): whether c is uppercase
ispunct(c): whether it is punctuation
isdigit(c): returns whether c is a hex digit 

therefore we can see isblank return whether c is blank

A

therefore we can see isblank(c): returns whether c is blank

20
Q

blanks are a container that allow you to associate a key value with a blanked value arbitrarily

A

maps are a container that allow you to associate a key value with a mapped value arbitrarily.

21
Q

the blank blank can be used to look up the mapped value

A

key value can then be used to look up the mapped value

22
Q

a map might associate a student names with test scores, allowing a test score to be looked up by name
therefore the map would have two types

A

string for names

double for test scores

23
Q

to use maps, first put blank at the top of your program

A

to use maps, first put #include at the top of your program

24
Q

to declare a map, declare it with the blank and blank types in blank
example: blank (anglebracket)string, double(anglebracket) variable;

A

to declare a map, declare it with the key and mapped value types in angle brackets
map(angle bracket)string, double(angle bracket) variable;

25
to place a value in the map, use blank | example: blank
to place a value in the map, use []: make sure colon after [] scores["Alice"] = 85.2;
26
to access a value from the map, use blank | example: blank
to access a value from the map use []: | example: cout << "Alice made a " << scores["Alice"] << "/n";
27
to get the number of items mapped, use blank | example: blank
to get the number of items mapped, use .size(): | example: int amount = scores.size();
28
a data type for building or disassembling strings from various data types modeled after input/output streams
stringstreams
29
strings are built using blank to place a new data into the stream, then blank to extract the string
new data using << | extract the string using .str( )
30
first put blank at the top of your program
first put #include sstream
31
#include sstream gives use the blank data type to use
stringstream stream; | the data type stringstream
32
use blank to place data into the stringstream as you would cout
<
33
example: for placing data into the stringstream
stream << 123 << " " << 456.78
34
Extract the string with blank
extract the string with .str( );
35
example of extracting the string
string s = stream.str( );
36
to extract data, first load a string into the stringstream using blank
.str( ):
37
example of extracting data
stream.str("123456.78")
38
extract information with >> | example
int x; stream >> x; double y; stream >> y;
39
You can also use blank with stringstream:
getline( ) string my_string; getline(stream, my_string);
40
stringstream is blank ordered or unordered
ordered
41
cin operator goes up to blank
spaces
42
getline goes up to blank
\n