How to change constant values?

Answers were Sorted based on User's Feedback



How to change constant values?..

Answer / ravi

Make it as mutable

Is This Answer Correct ?    14 Yes 3 No

How to change constant values?..

Answer / udit

const int var=10;
*(int *)&var=20;
this syntex change the constat value

Is This Answer Correct ?    15 Yes 10 No

How to change constant values?..

Answer / rajesh

use const_cast<...>

Is This Answer Correct ?    6 Yes 2 No

How to change constant values?..

Answer / ravi

can't change untill recomile

Is This Answer Correct ?    0 Yes 1 No

How to change constant values?..

Answer / asif karim

#include <stdio.h>
#include<iostream>
using namespace std;

void main()
{
const int var=10;
int a;
a=*(int* )& var=20;
cout<<a;
}

Is This Answer Correct ?    3 Yes 10 No

How to change constant values?..

Answer / edward

you can't change

Is This Answer Correct ?    5 Yes 13 No

Post New Answer

More C++ General Interview Questions

Search for: what is pair in c++?

0 Answers  


What is a Default constructor?

1 Answers  


Differentiate between a copy constructor and an overloaded assignment operator.

0 Answers  


What is a storage class?

0 Answers  


5. Can inline functions have a recursion?

4 Answers  






Give 2 examples of a code optimization?

4 Answers  


How do you master coding?

0 Answers  


How to reduce a final size of executable?

3 Answers  


Explain the benefits of proper inheritance.

0 Answers  


What are enumerations?

0 Answers  


What are the techniques you use for debugging?

1 Answers   Adtran,


Explain calling an object's member function(declared virtual)from its constructor?

1 Answers  


Categories