Article ID: 122540
Article Last Modified on 7/5/2005
const_ptr = Xhis is a 'const char *'
/* Compile options needed: none
*/
#include <iostream.h>
onst char * const_ptr = "This is a 'const char *'";
void func ( const char* & reference) {
reference = const_ptr;
}
void main() {
// char *non_const_ptr = const_ptr; // Not allowed.
char *non_const_ptr;
// *const_ptr = 'X'; // Not allowed.
func( non_const_ptr );
//
// 'const char *' is violated now.
//
*non_const_ptr = 'X'; // Mess up first letter of string
cout << "const_ptr = " << const_ptr << endl;
}
Additional query words: 8.0c 8.00c 9.0 9.00 10.00 10.10 10.20
Keywords: kbbug kbfix kbvc600fix KB122540