Class definition:
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&)=&_compFunc<K> > class X {};
I want to define a class method outside of the class code block. like so:
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&)=&_compFunc<K> >
X<K, V, hashFunc, compFunc>::X() { }
g++ v.4.4.3 returns
error: default argument for template parameter for class enclosing ‘X::X()’
Why is the compiler complaining and how can i make it work?
You didn't declare or define a constructor for X
. In addition, you had repeated the default template parameters in your attempted X::X definition.
Here's the fixed code, main
-ified:
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&)=&_compFunc<K> >
class X
{
X();
};
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&) >
X<K, V, hashFunc, compFunc>::X() { }
int main()
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With