As I understand, pass by reference to pointers is another way to pass arguments; it's supposed to be cleaner than pass by pointers to pointers (since compiler does the work behind the scenes), but curious as how would I get it to insert at front of this linked list e.g.
struct node
{
int data;
node *next;
};
//using pass by ref to ptrs (i.e. cleaner version of pass by ptrs to ptrs) is ONLY available in C++
void insert_at_front(int data_, node *&front, node *&end)
{
node *newNode = new node;
node->data = data_;//NB: or you can use: (*node).data
if ( front == NULL && end == NULL )
{
front = &node;
end = &node;
node->next = NULL;
}
else
{
node->next = front;
front = &node;
}
}
int main()
{
node *front = NULL; node *end = NULL;
insert_at_front(88,front,end);//this doesn't work
return 0;
}