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

What is meant by entry controlled loop? What all C++ loops are exit controlled?

0 Answers   TCS,


what is the size of a class which contains no member variables but has two objects??? is it 1 or 2??

4 Answers  


How many lines of code you have written for a single program?

4 Answers   BoA,


Difference between pass by value and pass by reference?

0 Answers  


Explain operator overloading.

0 Answers  






Describe the advantages of operator overloading?

0 Answers  


Write about the stack unwinding?

0 Answers  


What is stack unwinding?

0 Answers  


Write a program which uses functions like strcmp(), strcpy()? etc

0 Answers  


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

0 Answers  


What is called array?

0 Answers  


Which programming language's unsatisfactory performance led to the discovery of c++?

0 Answers  


Categories