Write a program that uses const_cast to modify a const variable. [Hint: Use a pointer in your solution to point to the const identifier.]

What will be an ideal response?


```
#include
using namespace std;

int main()
{
const char c = 'A';
const char *ptr = &c;

cout << "c is " << *ptr;

*const_cast< char * > ( ptr ) = 'Z';

cout << "\nc is " << *ptr << endl;
} // end main
```
c is A
c is Z

Computer Science & Information Technology

You might also like to view...

How does indefinite postponement differ from deadlock?

What will be an ideal response?

Computer Science & Information Technology

When an AP accepts or rejects a wireless device it sends a(n) ____ frame.

A. association request B. association response C. authentication D. reassociation

Computer Science & Information Technology

In Microsoft Access, an entire row in a database table is known as a ________.

a) record b) field c) column d) primary key

Computer Science & Information Technology

The purpose of a message is to pass information to a method.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology