Basic C++ inheritance Flashcards

1
Q

What is the code for the intAtom class in C++?

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

What code do you need to ensure you include?

A

include <iostream></iostream>

using namespace std;

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

What is the code for CharAtom class?

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

What is the code for the GenericList class in C++?

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

What is the Node class code in C++?

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

What are the constructors for the generalList example classes from class (in C++)

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

What are the other method bodies in the GeneralList example from class (in C++)

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

What are virtual methods in C++?

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

What is going on with this code? What does it print? What does the & do?

A

List 1 is: ( *A* 34)

List 2 is: (* * ( *A* 34) 88)

List 1 is: (99 *A* 34)

List 2 is: (* *(99 *A* 34) 88)

&x gives the address of x. In the example above, we need to use &X because they are stack based variables and we need to pass it a pointer, so we grab one.

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

In the following code, why the &?

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

For the code below, why not make them heap-based?

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

When/where is it necessary to use the virtual keyword?

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

What is the ListItem code example from class (in C++)?

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

In general, how does polymorphism work with virtual in C++

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

When creating an abstract class in C++, what is the issue with virtual?

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

What is a vtable in C++?

A
17
Q

Is a virtual method/function in C++ the same as an abstract method in Java?

A
18
Q

How do you turn a virtual method in C++ into an abstract method (like in Java) that forces subclasses to implement the method?

A

As an exmaple

19
Q

What if the class I want to be abstract in C++ has no methods?

A
20
Q

How do you downcast or error check(equivalent to instanceof in Java) in C++ manually?

A
21
Q

For the following code, what happens when isDog( ) is sent to a Bird instance or isBird( ) to a dog?

A

NULL is returned, so we have to check it

22
Q

In general, in C++ how does Dynamic Class Binding work?

A
23
Q

What is C++’s built-in feature that checks types (like instanceof in Java)?

A