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
Q

to place a value in the map, use blank

example: blank

A

to place a value in the map, use []:
make sure colon after []
scores[“Alice”] = 85.2;

26
Q

to access a value from the map, use blank

example: blank

A

to access a value from the map use []:

example: cout &laquo_space;“Alice made a “ &laquo_space;scores[“Alice”] &laquo_space;“/n”;

27
Q

to get the number of items mapped, use blank

example: blank

A

to get the number of items mapped, use .size():

example: int amount = scores.size();

28
Q

a data type for building or disassembling strings from various data types
modeled after input/output streams

A

stringstreams

29
Q

strings are built using blank to place a new data into the stream, then blank to extract the string

A

new data using «

extract the string using .str( )

30
Q

first put blank at the top of your program

A

first put #include sstream

31
Q

include sstream gives use the blank data type to use

A

stringstream stream;

the data type stringstream

32
Q

use blank to place data into the stringstream as you would cout

A

<

33
Q

example: for placing data into the stringstream

A

stream &laquo_space;123 &laquo_space;” “ &laquo_space;456.78

34
Q

Extract the string with blank

A

extract the string with .str( );

35
Q

example of extracting the string

A

string s = stream.str( );

36
Q

to extract data, first load a string into the stringstream using blank

A

.str( ):

37
Q

example of extracting data

A

stream.str(“123456.78”)

38
Q

extract information with&raquo_space;

example

A

int x;
stream&raquo_space; x;
double y;
stream&raquo_space; y;

39
Q

You can also use blank with stringstream:

A

getline( )
string my_string;
getline(stream, my_string);

40
Q

stringstream is blank ordered or unordered

A

ordered

41
Q

cin operator goes up to blank

A

spaces

42
Q

getline goes up to blank

A

\n