Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Explain why Line 138 and 140 gives different results when the address is same for both. What do const cast actually do? OUTPUT CODE FOR
Explain why
Line 138 and 140 gives different results when the address is same for both.
What do const cast actually do?
OUTPUT
CODE FOR REFERANCE
#include
using namespace std;
int main() {
const int var1 = 10;
const int* ptr1 = &var1;
cout
cout
int* ptr2 = const_cast
*ptr2 = 3;
cout
cout
cout
return 0;
}
The old value of ptr1 is: 10 The old adress of ptr1 is: exglffo4 The new value of ptri is: 3 The new adress of ptr1 is: axglff04 The new value of varl is: 10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started