How do I resolve: "error C2039: '{ctor}' : is not a member of" in Visual Studio 2005?

Brock Woolf picture Brock Woolf · Dec 8, 2008 · Viewed 9.5k times · Source

I am extending a template class using C++ in Visual Studio 2005. It is giving me an error when I try to extend the template base class with:

template <class K, class D>
class RedBlackTreeOGL : public RedBlackTree<K, D>::RedBlackTree  // Error 1
{
 public:
  RedBlackTreeOGL();
  ~RedBlackTreeOGL();

and a second error when I try to instantiate the object:

RedBlackTreeOGL<double, std::string> *tree = new RedBlackTreeOGL<double, std::string>; // error 2

Error 1:

**redblacktreeopengl.hpp(27) : error C2039: '{ctor}' : is not a member of 'RedBlackTree' with [ K=double, D=std::string ] **

Error 2:

main.cpp(50) : see reference to class template instantiation 'RedBlackTreeOGL' being compiled

Answer

James Hopkin picture James Hopkin · Dec 8, 2008

The code is trying to inherit a constructor, not a class :-)

The start of the class declaration should be

template <class K, class D>
class RedBlackTreeOGL : public RedBlackTree<K, D>