Discussion 1: C++ Refresher Flashcards

1
Q

preprocessor directives

A

top of file with a #, processed before the compiler, #include, #define, (#ifdef, #ifndef, #endif), #pragma once

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

include

A

include replaces the directive with the content of the specified header or file

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

define (

A

define replaces all instances of identifier with replacement.

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

ifdef, ifndef, and #endif

A

identifiers allows sections to be complied if an identifier is/isnt defined

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

pragma once

A

makes source file to be included only once in a single compilation

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

char

A

1 byte | primitive type

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

std::string( char array )

A

char array

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

int (How many bytes, range)

A

4 bytes | -2.147 bil - 2.147 bil

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

unsigned int (How many bytes, range)

A

4 bytes | 0 to 4.294 bil

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

long (how many bytes, range)

A

8 bytes | -910^18 to 910^18

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

unsigned long (bytes, range)

A

8 bytes | 0 to 18*10^18

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

double (bytes, use case)

A

8 bytes | used for decimals

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

float (bytes, use case)

A

4 bytes | used for decimals

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

float vs double

A

float uses 4 bytes , double uses 8 bytes.
Use case: double is more precise

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

bool

A

1 byte | True or False

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

void

A

0 bytes | function not returning anything

17
Q

std::string( char array ) vs std::string

A

std::string(char array) is an array of characters while string is not

18
Q

auto (keyword)

A

derives the type of a variable on the fly

19
Q

decltype (keyword)

A

derives the type of variable by using another variable

20
Q

pointers

A

variable whose value is the memory address of another variable

21
Q

pointer (syntax)

22
Q

Address-of Operator

A

& | gets the memory address of a variable

23
Q

Dereference Operator

A
  • | gets the value at the memory address of a pointer
24
Q

pointer of array

A

points at the first element of the array

25
array vs vector
array is just a pointer to its first elements. It has no knowledge of where it ends
26
new (keyword)
dynamically allocates memory in the heap, and returns a pointer
27
delete (keyword)
used to deallocate heap memory. delete or delete[] , pointer is not destroyed but the item the pointing is referencing is.
28
memory leak
dynamic memory (heap) that is no longer being referenced and not deleted
29
passing into functions in c++
pass by pointer, or reference, if not it will create a copy of passed in argument
30
structs vs class
both create object, structs are public by default, while class is private by default
31
templates
used when we don't know the type it will receive. usually used at very low level
32
T o F: (Templates) We can write one template function that can be used for all data types including user defined types. Like sort(), max(), min(), etc
TRUE
33
T o F: (Templates) We can write one template class or struct that can be used for all data types including user defined types. Like LinkedList, Stack, Queue, etc...
TRUE
34
T o F: (Templates) Templates are an example of overriding
FALSE
35
const
variable is NOT allowed to change
36
What is mutable? int* const x
the memory address is locked, but the int value can change
37
What is mutable? const int* x or int const * x
The int cannot change, but the memory address can be changed.
38
What is mutable? const int * const x
The int and memory address cannot be changed.
39
const objects, can only be called by
const functions