Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews C Plus Plus Language Interviews:C++ Access ControlC++ COM ActiveXC++ ConstructorsC++ ContainersC++ Exception HandlingC++ FriendC++ InheritanceC++ Inline FunctionC++ New And DeleteC++ Operator OverloadingC++ Pointers & FunctionsC++ ProgrammerC++ ReferencesC++ Static DataC++ SyntaxC++ TemplateC++ Type CheckingC++ Virtual Functions
Copyright © 2018. All Rights Reserved
C++ Pointers & Functions Interview Question:
What is const pointer?
Submitted by: Administratorconst pointer is a pointer which you don't want to be pointed to a different value. That is, the location stored in the pointer can not change. We can not change where the pointer points. It is declared as:
type * const name
type is data type
name is name of the pointer
eg: char * const p
Since the location to which a const pointer points to can not be changed, the following code:
char ch1 = ‘A';
char ch2 = ‘B';
char * const p = &ch1;
p = &ch2;
will throw an error since address stored in p can not be changed.
Submitted by: Administrator
type * const name
type is data type
name is name of the pointer
eg: char * const p
Since the location to which a const pointer points to can not be changed, the following code:
char ch1 = ‘A';
char ch2 = ‘B';
char * const p = &ch1;
p = &ch2;
will throw an error since address stored in p can not be changed.
Submitted by: Administrator
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.