EXAM Flashcards

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
Q

What does the extraction operator do with whitespace?

A

It ignores leading whitespace

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

What is “»” called?

A

The extraction operator

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

What does getline() do?

A

Reads characters from a stream up to and excluding the delimiter

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

What is the syntax for using getline()?

A

getline(cin, input, [delimiter])

29
Q

What is the syntax for ignore?

A

cin.ignore(n, ch)

n = number of characters to ignore unless ch is encountered

30
Q

What does get() do?

A

Reads one character at a time

31
Q

Does get() ignore whitespace?

A

No

32
Q

What are the 4 condition states of a stream called?

A

ios: :goodbit
ios: :eofbit
ios: :failbit
ios: :badbit

33
Q

The iostate bit is set to what by default?

A

0

34
Q

What does it mean if the iostate bit is set to 1?

A

The state is in error

35
Q

What function is used to read the current condition of a stream state?

A

stream.rdstate()

36
Q

How do you test for valid stream?

A

if (!stream)

error code

37
Q

When cin fails, how do you set it back to default?

A

cin.clear();

38
Q

How do you convert a string to an int or a double?

A

stoi(string), stod(string)

39
Q

How to you instantiate a string with 10 characters all as ‘c’?

A

string s(10, ‘c’);

40
Q

What are 2 ways to instantiate a string as a copy of another string?

A
string s1 = s2;
string s3(s2);
41
Q

What is RAII?

A

Resource Acquisition is Initialization

42
Q

Is the string class an STL container?

A

No

43
Q

What function converts a number to a string?

A

to_string()

44
Q

What does ofstream::app do?

A

Appends to the end of the file being used as the output stream

45
Q

What does STL stand for?

A

Standard Template Library

46
Q

What are the 2 kinds of STL container?

A

Sequence container

Associative container

47
Q

What function is used for removing the last iteration of a container?

A

pop_back()

48
Q

What does O(1) mean?

A

An operation is done once

49
Q

What does O(log n) mean?

A

An operation is done less than n times

50
Q

What is an iterator?

A

A generalization of a pointer, but not a pointer

51
Q

What are the 3 main kinds of iterators?

A

Forward
Bidirectional
Random-Access

52
Q

What class does the map container use to store it’s values?

A

pair

53
Q

What are the 2 public members of the pair class?

A

first, second

54
Q

What is a predicate function?

A

A function that returns a bool

55
Q

What is data abstraction?

A

A design technique that separates the interface of a class from its implementation

56
Q

What is encapsulation?

A

The use of modifiers to separate the interface from implementation

57
Q

What is the difference between a class and a struct?

A

Struct has no access modifiers and only data members, class does not exist in C

58
Q

What access modifier do classes made with “struct” have by default?

A

Public

59
Q

What access modifier do classes made with “class” have by default?

A

Private

60
Q

What are the four access modifiers in C++?

A

public, private, protected, friend

61
Q

What is the default constructor called in C++?

A

Synthesized default constructor

62
Q

What is the preferred syntax for a constructor?

A

ClassName (type v, type w) :

property1(v), property2(w) {}

63
Q

Which STL container uses contiguous storage?

A

Vector

64
Q

What is the difference between a Vector and a Deque?

A

A Deque can be expanded or contracted from either end, whereas a vector is restricted to the back

65
Q

Which sequential container is best for inserts, erases and sorting?

A

Lists

66
Q

Do lists have direct access?

A

No

67
Q

How are sets implemented?

A

Binary search trees

68
Q

What is a “stop” test with streams?

A

if (!stream)

error message

69
Q

What is a “go” test with streams?

A

while (getline(stream, variable)) {
operations
}