Search code examples
c++visual-studio-2005templatesclass-designvisual-c++-2005

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


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


Solution

  • 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>