Hi,
This is the code segment:

template<class type> void merge_sort(type inputs[], int p, int r, int (*comp)(type, type));

typedef struct
{
	vertex vertices[MAX_VERTEX];
	int number_vertices;
	int adj_matrix[MAX_VERTEX][MAX_VERTEX];
} graph;

int compare_vertex(vertex v1, vertex v2) 
{
	if (v1.f < v2.f)
	{
		return -1;
	}
	else if (v1.f > v2.f)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main() {
        graph* g; 
        int (*cmp)(vertex v1, vertex v2);
	cmp = compare_vertex;
	int num_vertices = g->number_vertices;
	merge_sort<vertex>(g->vertices, 0, num_vertices, cmp);
}

Why am I still getting no matching function? because as observed from the declaration of merge_sort it takes an array of template type, 2 int, 1 pointer to a function having 2 arguments of type. In the calling routine the merge_sort is called with template type vertex with arguments- an array of vertices, 2 int, and a function pointer taking 2 arguments of type vertex.

Thanks.

Are you sure you posted a relevant code snippet? The error message says:

error: no matching function for call to ‘merge(vertex*&, int&, int&, int&)

So there should be a call to merge(...) , but there isn't.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.