Q:

C++ : function gets pointer or refernce

There is something very unclear to me to when a function should get a pointer or a reference .
Lets say im implementing BFS . here is my implementation :
// Assuming There is a class Node :
class Node {
    public:
    int val;
    bool visited;
    list<Node*> neighbours;
};

void BFS (Node* root) {
    if(root == NULL) {
        return ;
    }

    queue<Node*> Q;
    Q.push(root);

    while(!Q.empty()){
        Node* temp = Q.front();
        Q.pop();

    for(list<Node*>::iterator it = root->neighbours.begin() ; it != root->neighbours.end() ; it++){
            if((*it)->visited == true) continue;
            Q.push((*it));
            (*it)->visited = true;
        }

        if(!Q.empty()){
            cout << temp->val << ",";
        } else {
            cout << temp->val << endl;
        }
    }
}

My question is : should the function BFS get a pointer or a reference and why ?
also , id love to hear some more comments on the implementation itslef. 
Thanks a lot !

A:

There could be different approaches and different reasons why to use pointer as a function argument

If you are going to do pointer arithmetic inside your BFS function you should use pointer as an argument.
Sometimes it's useful to check if pointer is null and do some actions depending on it. 

It may seem that this is not a big reason to use pointer as an argument, but null can hold very important information on it. For example there are binary search tree implementations where null pointer shows that the node is a leaf.
In your example also you check if root is null and return in that case.

