I created a templated class which searches for a path between 2 points in a graph. The template parameter takes in a class representing the graph.

template <class graph_type>
class Graph_PathSearch
{
public:
Graph_PathSearch(&graph_type G, int startIndex, int endIndex);
};


The graph object is declared as a pointer.

NavGraph* m_pGraph;
m_pGrapn = new NavGraph(true);


I then instantiated the path search using this statement:

Graph_PathSearch<NavGraph*> StartSearch(*m_pGraph,startNode,destNode);


But the compiler produced a long string of compile errors. However, when I changed the template parameter from <NavGraph*> to <NavGraph>, there were no more compile errors.

I would like to know when is the right time to use a pointer as a template parameter, since the graph is declared as a pointer but using a pointer as a template parameter is incorrect in this case?