CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    10

    Problem with templates

    I have some (weird?) problem with a template class I'm writing. First, I have a template class called CTree for storing generic data. Then, I declare an instance of it. When I link the whole program, I get an error: external symbol not defined "public: int const __thiscall IcdTree::AddNode ... ".
    What could that be? The method it references is defined, and the .cpp file is included in the project.

    Thanks, Martin


  2. #2
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: Problem with templates

    Is the sourcecode of your templateclass written in the headerfile of your template ?


  3. #3
    Join Date
    Apr 1999
    Posts
    10

    Re: Problem with templates

    All the code for the template class itself is in the header file.
    To specify the problem: I have a class template called CTree <T>, which implements a generic tree. In another class, say CXYTree, I instantiate it with a member variable:
    CTree<struct Something> m_tMem.
    The linker error occurs when I try to use a member of CXYTree in my document, e.g. CXYTree::AddNode(...). The linker then complains that the symbol CXYTree::AddNode(Something const &) is not defined.


  4. #4
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: Problem with templates

    You have to call the method of your member variable:

    m_tMem.AddNode(...);



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured