EXAM Flashcards

(69 cards)

1
Q

How many primitive types does C have?

A

14

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

How many primitive data types does C++ have?

A

18

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

How many char data types does C++ have?

A

5

char, unsigned char, wchar_t, char16_t, char32_t

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

What data type did C++ add that C didn’t have?

A

Boolean

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

How many bytes is a wchar_t?

A

2 or 4

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

What does the sizeof operator return?

A

The size of a data type in bytes

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

What header is needed to find the min and max of data types?

A

include < limits >

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

What is the new syntax for casting a data type?

A

int val = static_cast< data_type >(number);

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

What is a constexpr

A

An expression that can be evaluated at compile time.

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

What is the new syntax for specifying a type alias?

A

using wages = double;

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

What two keywords can be used for type aliases?

A

typedef OR using

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

What is std

A

The C++ standard library namespace

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

What does using a namespace help avoid?

A

Name collision from multiple programs using the same identifiers

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

What header is needed for IO operations from the console?

A

< iostream >

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

What header is needed for IO operations for files?

A

< fstream >

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

What header is needed for IO operations with a string?

A

< sstream >

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

What are the input/ouput objects for a string?

A

istringstream, ostringstream

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

What is “ < < “

A

The Insertion Operator

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

What does endl do?

A

Adds a newline and flushes the stream

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

How do you set precision with stream manipulators?

A

setprecision(2)

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

How do you set the width using a stream manipulator?

A

setw(9)

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

What are the objects/functions included in < iomanip >

A
setfill(ch)
setprecision(n)
setw(w)
setbase(b)
put_money(int)
put_time()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is held in < locale > header?

A

Geographic location features for formatting

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

What argument is passed to a locale object to specify current locale?

A

locale loc(“”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the extraction operator do with whitespace?
It ignores leading whitespace
26
What is ">>" called?
The extraction operator
27
What does getline() do?
Reads characters from a stream up to and excluding the delimiter
28
What is the syntax for using getline()?
getline(cin, input, [delimiter])
29
What is the syntax for ignore?
cin.ignore(n, ch) | n = number of characters to ignore unless ch is encountered
30
What does get() do?
Reads one character at a time
31
Does get() ignore whitespace?
No
32
What are the 4 condition states of a stream called?
ios: :goodbit ios: :eofbit ios: :failbit ios: :badbit
33
The iostate bit is set to what by default?
0
34
What does it mean if the iostate bit is set to 1?
The state is in error
35
What function is used to read the current condition of a stream state?
stream.rdstate()
36
How do you test for valid stream?
if (!stream) | error code
37
When cin fails, how do you set it back to default?
cin.clear();
38
How do you convert a string to an int or a double?
stoi(string), stod(string)
39
How to you instantiate a string with 10 characters all as 'c'?
string s(10, 'c');
40
What are 2 ways to instantiate a string as a copy of another string?
``` string s1 = s2; string s3(s2); ```
41
What is RAII?
Resource Acquisition is Initialization
42
Is the string class an STL container?
No
43
What function converts a number to a string?
to_string()
44
What does ofstream::app do?
Appends to the end of the file being used as the output stream
45
What does STL stand for?
Standard Template Library
46
What are the 2 kinds of STL container?
Sequence container | Associative container
47
What function is used for removing the last iteration of a container?
pop_back()
48
What does O(1) mean?
An operation is done once
49
What does O(log n) mean?
An operation is done less than n times
50
What is an iterator?
A generalization of a pointer, but not a pointer
51
What are the 3 main kinds of iterators?
Forward Bidirectional Random-Access
52
What class does the map container use to store it's values?
pair
53
What are the 2 public members of the pair class?
first, second
54
What is a predicate function?
A function that returns a bool
55
What is data abstraction?
A design technique that separates the interface of a class from its implementation
56
What is encapsulation?
The use of modifiers to separate the interface from implementation
57
What is the difference between a class and a struct?
Struct has no access modifiers and only data members, class does not exist in C
58
What access modifier do classes made with "struct" have by default?
Public
59
What access modifier do classes made with "class" have by default?
Private
60
What are the four access modifiers in C++?
public, private, protected, friend
61
What is the default constructor called in C++?
Synthesized default constructor
62
What is the preferred syntax for a constructor?
ClassName (type v, type w) : | property1(v), property2(w) {}
63
Which STL container uses contiguous storage?
Vector
64
What is the difference between a Vector and a Deque?
A Deque can be expanded or contracted from either end, whereas a vector is restricted to the back
65
Which sequential container is best for inserts, erases and sorting?
Lists
66
Do lists have direct access?
No
67
How are sets implemented?
Binary search trees
68
What is a "stop" test with streams?
if (!stream) | error message
69
What is a "go" test with streams?
while (getline(stream, variable)) { operations }