Page 243 - DCAP404 _Object Oriented Programming
P. 243
Object-oriented Programming
Notes Self Assessment
Fill in the blanks:
5. C++ also knows that you will store only ………………… in age, not floating-point or
double floating point data.
6. Arithmetic and …………………….. operations can be performed on the pointers.
7. Due to the ability of a pointer to directly refer to the value that it points to, it becomes
necessary to specify in its ……………………. which data type a pointer is going to point to.
11.3 Pointer to Pointers
Pointer is a variable, which contains address of a variable. This variable itself could be another
pointer. Thus, a pointer contains another pointer’s address as shown in the example given
below:
void main()
{
int i = 3; int *j, **k;
j = &i; k = &j;
cout<<“Address of i = \n”<< &i;
cout<<“Address of i = \n”<<j;
cout<<“Address of i = \n”<<*k;
cout<<“Address of j = \n”<<&j;
cout<<“Address of j = \n”<<*k;
cout<<“Address of k = \n\n”<<&k;
cout<<“Value of j = \n”<<j;
cout<<“Value of k = \n”<<k;
cout<<“Value of i = \n”<<i;
cout<<“Value of i = \n”<<*(&i);
cout<<“Value of i = \n”<<*j;
cout<<“Value of i = \n”<<**k;
}
The following figure would help you in tracing out how a program prints the output.
i i k
3 6485 3276
6485 3276 7234
Output: Address of i = 6485
Address of i = 6485
Address of i = 6485
Address of j = 3276
236 LOVELY PROFESSIONAL UNIVERSITY