Functions Error

Hi! I have this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
template<class T>
	void map(int (*f)(int), Node<T> *node)
		{	
			if(node == NULL) return;
			map(f, node->Left);
			f(node->data);
			map(f, node->Right);
		}

	template<class T>
	int plus(int x)
		{
			x = x + 1;
		}

	template<class T>
    void Tree<T>::Root()
      {
		Print(root);
		cout << endl;
		Tree<T> B;
		Copy(B.root, root);
                map(plus, B.root);
		Print(B.root);
      }


And I get this erroron line 23:
cannot convert parameter 1 from 'int (__cdecl *)(int)' to 'int (__cdecl *)(int)'


Do you have an idea what's wrong with the code? I can't find the mistake. :/
Last edited on
¿why is `plus()' a template?
Also http://www.cplusplus.com/doc/tutorial/functions2/
The compiler can not determine what is the type of T in the plus definition.
plus() should not be a template as it does not use the template parameter T. It would be fine as a normal function.

Lol, thanks. I didn't expect that the template can be the problem :)
Topic archived. No new replies allowed.