class template specialization - incomplete type

Hi,
I have a problem, this code won't compile. It says the class foo<10, int> is incomplete...
Can someone here tell me what's wrong, and how to correct it?

(Never mind the names):
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
26
27
28
29
30
31
32
33
#include <iostream>
using namespace std;

// general template
template<int N, typename type>
class foo
{
public:
	type arr[N];
public:
	bool lol()
	{
		cout << "lol" << endl;
		return true;
	}
};

// supposed to overload function lol() if the first template parameter is 10
template<typename type>
bool foo<10, type>::lol()
{
	cout << "lol it's 10" << endl;
	return false;
}

int main()
{
	foo<10, int> bar;
	cout << bar.lol() << endl;
	foo<5, int> baz;
	cout << baz.lol() << endl;
	return 0;
}
Partial Specialization of template functions are not allowed


EDIT:
I was going to add something but I'll leave it for the moment.
Last edited on
Topic archived. No new replies allowed.