Problem with template classes

I have this classes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class FunctMenuScreen
{
public:
	virtual ~FunctMenuScreen() = 0;
	virtual void operator()() = 0;
};


template<class FunctObj>
class FunctMenu : public FunctMenuScreen
{
typedef void (FunctObj::*FunctMenuAction)();

private:
	FunctObj* object;
	FunctMenuAction action;

public:
	FunctMenu(FunctObj*, FunctMenuAction);
	~FunctMenu() {};
	void operator()();
};


and in class MainMenu in some function I have this:

FunctMenu<MainMenu>* test = new FunctMenu<MainMenu>(this, &MainMenu::exit);

and linker show this error:
undefined reference to `FunctMenu<MainMenu>::FunctMenu(MainMenu*, void (MainMenu::*)())'


I compile it by GCC C++ Compiler on Linux.
What have I wrong? Please help, thank you
With templates you must keep the function definitions visible everywhere they are used, so you should keep them on the header
That isn't the problem. Of course I have classes FunctMenuScreen and FunctMenu at one header file, their functions definitions in source file. And the same with class MainMenu.
The function definitions of a template class need to be in the header, not the source file.
Thank you. How could I possible forget that!!! Thank you very much.
Topic archived. No new replies allowed.