problem of inheriting from a STL function class

My program can't be compiled through by GCC 4.3.3. The part of the program causing the problem is simplified as the following short code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <functional>

using namespace std;

class op : public unary_function<int,int> {
public:
	int operator()(int) {}
};

class test {
public:
	void func(unary_function<int,int> & o = op()) {}
};

int main()
{
} 

The compiler complained that the type of the default argument is not comply with the type of the parameter. I don't know why this happened. Please help me out. Thanks!
The problem is that the function parameter is a reference but the default value is a temporary.
I believe that you want a const reference void func ( const unary_function<int,int> & o = op() ) {}
Thanks. The problem is updated which is pasted at http://www.cplusplus.com/forum/general/28555/ . The problem is still there after the const is added.
Topic archived. No new replies allowed.