Lecture 6: Constants Flashcards

1
Q

Initializer list is used for

A

const data members

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

Syntax of initializer list

A

Class::Class(int a, int b): A(a), B(b)

{}

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

Values are assigned in the initializer list in what order?

A

Order of declaration in class

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

When can the value of a const object be changed

A

Constructor and destructor

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

What is the main issue with const object?

A

Cannot access non const member function

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

Syntax for const member functions

A
int Date::get_month() const
{}
//both prototype and header
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Both const and non const member functions can be called by

A

non const objects

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

3 functions that cannot be declared const

A

constructors
destructors
static member functions

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

Syntax of pointer to object

A

Date date, * dptr;

dptr = &date;

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

Syntax of const pointer to object

A
Date date;
Date * const dptr = &date;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Syntax of pointer to const object

A

Date date;

const Date * dptr = &date;

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

Syntax of const pointer to const object

A
Date date;
const Date * const dptr = &date;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In const member functions, this pointer is passed as

A

const pointer to const object

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