Compare and contrast mutable and const_cast. Give at least one example of when one might be preferred over the other.

What will be an ideal response?


Operator const_cast is used to cast away const or volatile qualifications. Users of a class usually will not be aware of const_cast operations, because this implementation is typically hidden. Storage-class specifier mutable allows a variable to be modified even if the object is const. Users of the class are not likely to be aware of a mutable member. Members that are mutable usually correspond to some “secret” implementation. mutable members are always modifiable, whereas const_cast operations are confined to the line where the cast is performed.

Computer Science & Information Technology

You might also like to view...

An appointment becomes a(n) ____ when people and other resources are invited.

A. event B. meeting C. conference D. gathering

Computer Science & Information Technology

If your work email address requires additional information to set up your account, where you do place that server information?

What will be an ideal response?

Computer Science & Information Technology

Color can be copied from one object or table on a slide to another with the ________ tool

A) Cut and Paste B) Eyedropper C) Texture D) Gradient

Computer Science & Information Technology

Which of the following kinds of storage is NOT used by NAS and SAN solutions?

A. disk B. flash memory C. optical disc D. tape

Computer Science & Information Technology