lecture three: class, object, and operator overloading Flashcards

(9 cards)

1
Q

what are constructors used for?

A

initialize objects upon declaration

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

are constructors called implicitly or explicitly?

A

they are called implicitly when an object is initialized, but can also be called explicitly

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

how do you pass information to constructors?

A

using parameters

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

how can you make a class/ADT look like part of the c++ language? (instead of a.add(b) it’s a + b)

A

by overloading operators

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

are friend functions methods?

A

no

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

do friend functions get the ::?

A

no

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

all classes need a __________

A

default constructor

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

why do all classes need a default constructor?

A

If you declare an array of a type which does not have a default constructor, you get an error. The default constructor is called for each element of the array.

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