Basic C++ inheritance Flashcards Preview

Comp 2150 > Basic C++ inheritance > Flashcards

Flashcards in Basic C++ inheritance Deck (23):
1

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

A image thumb
2

What code do you need to ensure you include?

#include

using namespace std;

3

What is the code for CharAtom class?

A image thumb
4

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

A image thumb
5

What is the Node class code in C++?

A image thumb
6

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

A image thumb
7

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

A image thumb
8

What are virtual methods in C++?

A image thumb
9

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

Q image thumb

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.

10

In the following code, why the &?

Q image thumb

A image thumb
11

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

Q image thumb

A image thumb
12

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

A image thumb
13

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

A image thumb
14

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

A image thumb
15

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

A image thumb
16

What is a vtable in C++?

A image thumb
17

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

A image thumb
18

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

As an exmaple

A image thumb
19

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

A image thumb
20

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

A image thumb
21

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

Q image thumb

NULL is returned, so we have to check it

22

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

A image thumb
23

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

A image thumb