let's say I'm building a BST (binary search tree) w/ node as such:
1 2 3 4 5 6 7 8 9 10 11 12 13
struct bst_node//Binary search tree node
{
int data;
bst_node* left;
bst_node* right;
};
int main()
{
bst_node* root = NULL;
return 0;
}
So for outputs for point 3, I sort of understand why it doesn't work when we use dereference operator...:
1) if it was: cout << root << endl;//This would be address of what pointer root pts to which is address 0
2) if it was: [code]cout << &root << endl;//This would be the address of the the declared root pointer itself since a pointer is a variable and it takes up space so it must exist somewhere in memory
3) if it was: [code] cout << *root << endl;//program crashes, is this b/c a root is not exactly a pointer...I'm not sure how to explain so that's why we have to use right arrow operator to access members: data, left, right.
I thought it was b/c of the fact that a bt_node is a special pointer for the way I'm using it but I guess I shouldn't go too deep into details unless it's useful as a programmer, I don't want to get into history I mean...so I'll leave it at that,thanks