Answered step by step
Verified Expert Solution
Link Copied!

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?

image text in transcribedOUTPUT

image text in transcribedCODE FOR REFERANCE

#include

using namespace std;

int main() {

const int var1 = 10;

const int* ptr1 = &var1;

cout

cout

int* ptr2 = const_cast (ptr1); // const_cast type should be same

*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: 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago