Part 1 - Introduction Flashcards

1
Q

What are the 6 phases of developing a program in C++?

A

1) Edit
2) Preprocess
3) Compile
4) Link
5) Load
6) Execute

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

What is a member function?

A

A method of a class

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

When is a default no argument constructor generated?

A

If we do not provide our own constructor for the class

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

How many bits does a char have?

A

8

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

How many bits does a short have?

A

16

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

How many bits does a long have?

A

32

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

How many bits does an int have?

A

Usually 32

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

How many bits does a long long have?

A

64

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

How many bits does a float have?

A

32

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

How many bits does a double have?

A

64

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

How many bits does a long double have?

A

128

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

What 3 areas are data stored in during execution?

A

static area

stack

heap

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

What is the static area used for?

A

Storing items whose lifetime is the duration of the program

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

What is the stack used for (wrt data storage)?

A

Local variables in functions, whose lifetime is the invocation of a function

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

What is the heap area used for?

A

Dynamic items whose lifetime is controlled by the programmer

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

What 6 elements does a variable have?

A

Type - primitive or classes

Lifetime - how long it exists for

Scope - what can see it while it is alive

Name

Size (in memory)

Value

17
Q

What are the 5 storage classes?

A

Automatic - for local variables existing only when the block in which the variables are defined is active

Register - for local variables, fast access, rarely used

Mutable - for class members to make them always modifiable even in a const function or a member of a const object

External - to make the variable globally accessibly within the program

Static - for variables that last the entire lifetime of the program

18
Q

How many times can a static variable or class be initialised?

A

Once

19
Q

Why does the auto keyword rarely need to be used?

A

Local variables are usually stored on the stack anyway so will only be alive while the function is executing

20
Q

What constraints does a const member function have?

A

Cannot change values of members of the object to which it is applied

21
Q

What must be done with a static variable when it is declared?

A

Initialised with a value

22
Q

Where must a global variable be defined?

How is it then accessed from other files?

A

Outside of any class or function

extern int a; at the top of the file or header

23
Q

In this code fragment:

int a = 0; // global

……

int myFunc() {

char a = ‘x’;

……

};

How would the global variable be accessed from within myFunc()?

A

::a