C++ Problem with a class template
Why won't this template compile?
template <class K, class V = Referenced>
class Cache
{
public:
Cache();
...
};
template <class K, class V>
Cache::Cache() <==== location of compiler error (see 开发者_JAVA技巧below)
{
...
}
ERROR error: 'template<class K, class V> class Cache' used without template parameters
You need to specify the template parameters:
template <class K, class V>
Cache<K, V>::Cache()
{
...
}
template <class K, class V>
Cache<K,V>::Cache() // Specify the template parameters
{
//...
}
Try this:
template <class K, class V>
Cache<K, V>::Cache()
{
...
}
Notice the template parameters following the class name.
精彩评论