Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 96421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:48:44+00:00 2026-05-10T23:48:44+00:00

I’m getting some really wierd linking errors from a class I wrote. I am

  • 0

I’m getting some really wierd linking errors from a class I wrote. I am completely unable to find anything that will describe what is happening.

Visual Studio (Windows XP)

players.obj : error LNK2019: unresolved external symbol ‘public: __thiscall TreeNode::TreeNode(void)’ (??0?$TreeNode@VPlayer@@@@QAE@XZ) referenced in function ‘public: __thiscall PlayerList::PlayerList(void)’ (??0PlayerList@@QAE@XZ)

Xcode (OSX 10.5)

Undefined symbols: ‘TreeNode::~TreeNode()’, referenced from: PlayerList::~PlayerList()in players.o

Header File: generics.h

class TreeNode : public BaseNode{ public:     const static int MAX_SIZE = -1; //-1 means any size allowed.      const static int MIN_SIZE = 0;     //getters     int size() const;     vector<C*> getChildren() const;     //setters     void setChildren(vector<C*> &list);     //Serialization     virtual void display(ostream &out) const;     virtual void read(istream &in);     virtual void write(ostream &out) const;     //Overrides so SC acts like an array of sorts.      virtual C* get(int id) const;      virtual int get(C *child) const;     virtual bool has(C *child) const;     virtual C* pop(int id);     virtual void push(C *child);     virtual TreeNode& operator<< (C *child); //append     virtual void remove(int id); //Clears memory      virtual void remove(C *child); //Clears memory      //Initalizers     TreeNode();     TreeNode(istream &in);     TreeNode(long id, istream &in);     TreeNode(BaseNode* parent, istream &in);     TreeNode(long id, BaseNode* parent);     TreeNode(long id, BaseNode* parent, istream &in);     ~TreeNode();     string __name__() const{ return 'TreeNode'; } protected:     void clearChildren();     void initalizeChildren();     vector<C*> _children; }; 

Code from a subclass of TreeNode

PlayerList::PlayerList() : TreeNode<Player>(){} PlayerList::PlayerList(istream &in) : TreeNode<Player>(in){} PlayerList::~PlayerList(){} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:48:44+00:00Added an answer on May 10, 2026 at 11:48 pm

    When you define your template in a .cpp file, you have to explicitly instantiate it with all the types / template parameters known the template will be used beforehand like this (put it in the .cpp file):

    template class TreeNode<Player>; 

    If you don’t know with which template parameters the template will be used, you have to put all the definitions into the header. like

    template<typename T> class TreeNode { public:    TreeNode() /* now, also put the code into here: */ { doSomething(); } }; 

    The reason is that when you are going to use the template from somewhere, the compiler has to be able to generate the code for that specific instantiation of the template. But if you place the code into a .cpp file and compile it, there is no way for the compiler to get its hands on the code to generate the instantiation (except when using the infamous export keyword, which is only supported by very few compilers).

    This is also an entry in my C++ Pitfalls answer: What C++ pitfalls should I avoid?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 115k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For interfaces, you'll want to use a PTypeInfo pointer, which… May 11, 2026 at 10:27 pm
  • Editorial Team
    Editorial Team added an answer I don't think there is a per-environment variable limit on… May 11, 2026 at 10:27 pm
  • Editorial Team
    Editorial Team added an answer Would: results.AddRange(objects.Select(obj => ApplyFormula(obj))); do? or (simpler) var results =… May 11, 2026 at 10:27 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.