good evening everybody, when i try to understand deep about constant pointer, pointer to constant, raise on with multi-level pointer, i got trouble.
Code:
#include <iostream>
using namespace std;
int main() {
/* const int*** a; // ->**a is a pointer level 1
int** b; // ->*b is a pointer level 1
**a = *b;
*/
int x = 2;
int* y = &x;
int** z = &y;
int*** t = &z;
int**** k = &t;
const int*** b = new const int**;
**b = ***k;
cout << "k before changed: " << ****k << ", " << "*y = x = " << *y;
/* const int**** a = &t;
int*** b;
***a = **b;
*/
// a = b;
return 0;
}
When i try to compile this code no error occur, but when runs executable file, output: segmentation fault.
Thanks for any repy.