Chapter 29 Flashcards

1
Q

What are abstract classes

A

To implement an abstract concept. Abstract classes can not be instantiated. It can inherit.

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

how we define pure virtual function in c+++

A

virtual void draw() = 0;

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

Does not we need to use body of virtual function most often

A

Yes

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

Does the class having pure virtual function(s) becomes abstract and then it can not be instantiated.

A

Yes

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

What happened to derived class which base class has virtual function

A

Derived class also remain abstract until we make the virtual function non-pure. We do it by over-riding the virtual function(s) in base class and remove 0 from its deceleration.

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

Does order of execution of destructor reverse than constructor

A

Yes. First called derived class destructor, then its base class and then its base class.

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

Can we make the destructor virtual

A

Yes

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

What is the use of virtual functions

A
  • To inherit interface and implementation

- Just inherit interface (pure virtual)

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

What is VTable

A

Compilers build a VTable (virtual function table) array for each class having virtual functions. A vtable array contains a pointer for each its associated virtual function.

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

How compiler deals with virtual functions and non-virtual functions

A

For non-virtual functions compiler just generate the code to call the function.
For virtual functions, compiler generates code to
- access the object
- access the VTable
- call the associated function.

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

Does polymorphism and virtual function a over head

A

Yes

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