Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fig. 8.11 Attempting to modily a constant pointer to nonconstant data Constant Pointer to Constant Data The minimum access privilege is granted by a constant

image text in transcribed
Fig. 8.11 Attempting to modily a constant pointer to nonconstant data Constant Pointer to Constant Data The minimum access privilege is granted by a constant pointer to constant data. Such a pointer always points to the same memory location, and the data at that location cannor be 8.6 Selection Sort Using Pass-by-Reference 343 modified via the pointer. This is how an array should be passed to a function that only reads the array, using array subscript notation, and does not modify the array. The program of Fig. 8.12 declares pointer variable ptr to be of type const int const (line 13). This dec laration is read from right to left as "ptr is a constant pointer to an integer constant." The figure shows the error messages generated when an attempt is made to modify the data to which ptr points (line 17) and when an attempt is made to modify the address stored in the pointer variable (line 18). No errors occur when the program attempts to dereference ptr (line 15), or when the program attempts to output the value to which ptr points, be cause neither the pointer nor the data ir points to is being modified in this statement. 1 // Fig. 8.12: fig08 12.cpp 2 W/ Attempting to modify a constant pointer to constant data. 3 #include

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 Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

a. Do team members trust each other?

Answered: 1 week ago