Accessing a Pointer to Pointers's value

How do you access a pointer to pointer's value?
1
2
3
4
5
6
7
8
9
10
11
12
13
int * p;

int **pp;

pp = p;//pointing to our pointer

int a;
*pp = &a;

//Dilemma here

//how do I access "a" from pp.
//Is it **pp? 

Is it **pp?


Yes.

p is an int**

therefore

*p is an int*

therefore

**p is an int
1
2
3
4
5
6
7
8
int a, *b, **c;
a = 5;
b = &a;
c = &b; //&&a

cout << a << endl;
cout << *b << endl;
cout << **c << endl;
5
5
5
or
1
2
3
4
5
6
7
8
9
10
int a, *b, **c;
c = new int*;
*c = new int;
b = *c;
*b = 5;
a = *b;

cout << a << endl;
delete b;
delete c;
5

(I hope I did all that right...)
Last edited on
Topic archived. No new replies allowed.