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 7640905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:47:23+00:00 2026-05-31T08:47:23+00:00

I have the following templated classes, template <typename Real> class Marker { typedef Wm5::Vector3<Real>

  • 0

I have the following templated classes,

template <typename Real>
class Marker {

 typedef Wm5::Vector3<Real> Position ;
 typedef Wm5::Vector3<Real> Normal ;
 typedef Wm5::Vector3<Real> Color ;

 public:

  Marker(int id = -1, Position position = Wm5::Vector3<Real>::ZERO, Normal normal = Wm5::Vector3<Real>::ZERO, Color color = Wm5::Vector3<Real>::ZERO)
: id_(id), position_(position), normal_(normal), color_(color), cluster_(-1) {}

  ~Marker() {}

 private:

  int id_ ;
  Position position_ ;
  Normal normal_ ; 
  Color color_ ;
  int cluster_ ;

};


template <typename T> 
class MarkerSet {

    typedef Marker<T> MarkerT ;      
    typedef std::vector<MarkerT> MarkerVector ;

public:

    MarkerSet::MarkerSet(int id = -1, MarkerVector markers = MarkerVector()) 
   {id_ = id; markers_ = markers;}      

   MarkerSet::~MarkerSet() {}

private:

    int id_ ;   
    MarkerVector markers_ ;

} ;

When I try to create a MarkerSet object by

MarkerSet<double> markerSet ; 

Getting this linker error,

error LNK2001: unresolved external symbol "public: __thiscall     MarkerSet<double>::MarkerSet<double>(int,class std::vector<class Marker<double>,class std::allocator<class Marker<double> > >)" (??0?$MarkerSet@N@@QAE@HV?$vector@V?$Marker@N@@V?$allocator@V?$Marker@N@@@std@@@std@@@Z)

I would be extremely grateful if somebody could give me a pointer in the right direction with regards to what I have done wrong.

Edit:

Ok I have narrowed it down to something rather odd.

in .h

  MarkerSet(int id = -1, MarkerVector markers = MarkerVector()) 
{id_ = id; markers_ = markers;}    

builds fine

Rather than in .h

 MarkerSet(int id = -1, MarkerVector markers = MarkerVector()) ;

in .cpp

 template <typename T>
 MarkerSet<T>::MarkerSet(int id, MarkerVector markers) {

  id_ = id ;
  markers_ = markers ;

}

Errors out in the way described above.

Any thoughts?

  • 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. Editorial Team
    Editorial Team
    2026-05-31T08:47:24+00:00Added an answer on May 31, 2026 at 8:47 am

    Can you try using a different compiler? I tried playing with it and the following works fine for me with gcc. I eliminated the Wm5 members as I don’t have those. Pasting the header and cpp:

    test.h

    #include <vector>
    
    template <typename Real>
    class Marker {
    
     public:
    
      Marker(int id = -1,int _position=1)
        : id_(id), position(_position){}
    
      ~Marker() {}
    
     private:
    
      int id_ ;
      int position ;
      Real r;
    
    };
    
    
    template <typename T> 
    class MarkerSet {
    
        typedef Marker<T> MarkerT ;      
        typedef std::vector<MarkerT> MarkerVector ;
    
    public:
    
        MarkerSet(int id = -1, MarkerVector markers = MarkerVector()) 
          {id_ = id; markers_ = markers;std::cout<<"Called"<<std::endl;}      
    
       ~MarkerSet() {}
    
    private:
    
        int id_ ;   
        MarkerVector markers_ ;
    
    } ;
    

    test.cpp

    #include <iostream>
    #include <vector>
    #include "test.h"
    
    using namespace std;
    
    
    int main(int argc, const char **argv) {
      cout<<"Hello"<<endl;
      MarkerSet<double> ms;
      return -1;
    
    }
    

    cmd:

    bash$ ./test
    Hello
    Called
    bash$ 
    

    Template class definition need to be in the header:

    Why do C++ template definitions need to be in the header?

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

Sidebar

Related Questions

I have the following templated function... template< class T > T *create_object( lua_State *L
assume that I have the following two template classes : template <class _A> class
Suppose we have the following template class template<typename T> class Wrap { /* ...
I have following two classes: template <size_t size> class Cont{ public: char charArray[size]; };
I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector,
I have the following template method declared in my interface: class IObjectFactory { public:
I have the following code: template <typename T> LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0);
I have the following pattern: template <int a, int b> class MyClass { public:
I have the following code: template <class T> struct pointer { operator pointer<const T>()
I'm slightly confused with template specialization. I have classes Vector2 , Vector3 which have

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.