referenes and pointers
what happens when we try to access the value at a NULL pointer position as in the following program
1 2 3 4 5 6 7 8 9 10
|
#include<iostream>
using namespace std;
int main()
{
int *ptr = NULL;
int &ref = *ptr;
cout << ref;
}
|
You are basically de-referencing a null pointer, which will result in a segmentation fault error if you attempt to run the program.
Why didn't you just run the program and find out yourself?
Topic archived. No new replies allowed.