Virtual Functions Flashcards

1
Q

what is override?

A

To help address the issue of functions that are meant to be overrides but aren’t, C++11 introduced the override specifier. Override can be applied to any override function by placing the specifier in the same place const would go. If the function does not override a base class function, the compiler will flag the function as an error.

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

what is final specifier when related to functions

A

It means we cannot override this function anymore

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

what is final specifier when related to class inheritance

A

it means this class cannot be inherited further

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

what is interface class?

A

when all the members of the class are pure virtual functions then that class is interface class.

Interface class just provides a placeholder for specifying what all functionality should be present in the base class and its upto the derived classes to implement the functionality the way they want

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

what is pure virtual function?

A

virtual function whose body is set to 0 is a pure virtual function

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

what is abstract class?

A

A class with one or more pure virtual function is abstact class and we cannot instantiate or have an object of abstract class.

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

Do Abstract classes have a virtual table?

A

Yes abstract classes have a virtual table.
Abstract classes still have virtual tables, as these can still be used if you have a pointer or reference to the abstract class. The virtual table entry for a pure virtual function will generally either contain a null pointer, or point to a generic function that prints an error (sometimes this function is named __purecall) if no override is provided

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