Chapter 32 Flashcards

1
Q

Can a generic program abstraction (function, class) can be parameterized with a type

A

Yes

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

Can there be any type of data in generic program abstraction

A

Yes

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

What are the advantages of generic programming

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

What are templates

A

Templates are the foundation of generic programming, which involves writing code in a way that is independent of any particular type. A template is a blueprint for creating a generic class or a function.

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

What are 2 kinds of templates

A
  • Function templates

- Class templates

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

What compiler do with templates

A

Compiler generates different type-specific copies from a single template

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

Can a function template be parameterized to operate on different types of data

A

Yes

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

Is it possible a function template may not have any parameter

A

Yes

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

Is it possible a template may not handle all types successfully

A

Yes

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