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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:07:13+00:00 2026-05-22T22:07:13+00:00

I’ve been programing a template structure and after make it work I decided to

  • 0

I’ve been programing a template structure and after make it work I decided to use it on some other project. The template consists in two files. ListOctree.cpp and ListOctree.h.
While they compile and run just fine on their own (I can run the structure self-test).

When using them on the other project, both ListOctree.cpp/.h are on the ./Util directory but while Visual Studio seems to find the .h file (I can use the .h declarations anywhere on the project), it seems like it can’t find the .cpp source file where all the code declared on the .h is declared.

The files are part of the project. ists tree is something like this:

program.cpp <-- includes "Util/ListOctree.h"
/Util
    ListOctree.cpp
    ListOctree.h

All the classes and functions from ListOctree belong to the Util namespace.

The error that Visual C++ throws is:
error LNK2019: símbolo externo “public: __thiscall Util::ListOctree::ListOctree(int)” (…) sin resolver …

Aprox. in english:
error LNK2019: external symbol “public: __thiscall Util::ListOctree::ListOctree(int)” (…) not resolved …

When rebuilding the solution the Util/ListOctree.cpp is compiled an the .obj file generated yet it seems not to be able to link it together

I can also post the .h file but I find it too long to post now.

Annex: where and how i’m using the .h file

#include "Util/ListOctree.h"
//...
void main (){
//...
    ListOctree<int>* a = new ListOctree<int>(8);
//...
}

Annex: Util/ListOctree.h

#ifndef __UTIL_LISTOCTREE
#define __UTIL_LISTOCTREE

//Conditional compilation flags

#undef _SELFTEST
#undef _DEBUG_LISTOCTREE

//Conditional compilation options
#ifdef _DEBUG_LISTOCTREE
 #undef  _DEALLOCATE_LISTS
 #define _SELFTEST
#endif

#ifdef _SELFTEST
 #include <iostream>
#endif

#ifdef _SELFTEST
 #include<assert.h>
#endif

#ifdef _DEBUG_LISTOCTREE
 #include <iostream>
#endif
/////////////////////////////////

#include <deque>
#include <list>
#include <iterator>
#include <math.h>
#include <exception>

//Remind me to never do this again. (xYz,XYz,XYZ,xYZ,xyz,Xyz,XyZ,xyZ,)
//A CAPS character means positive in the axis while a
//Lowercase character means negative
//FIXME Never used I think.
#define _xyz sons[0]
#define _xyZ sons[1]
#define _xYz sons[2]
#define _xYZ sons[3]
#define _Xyz sons[4]
#define _XyZ sons[5]
#define _XYz sons[6]
#define _XYZ sons[7]

namespace Util{
/**
 * @brief The node class
 *
 * Each node stores up to 8 sons, a parent pointer and, if it
 * is a Leaf node, a list of contents.
 */
template <typename T> class Node{
    //Attributes
public:
    ///An array with all the sons
    Node<T>* sons[8];
    ///A parent pointer
    Node<T>* parent;

    //The node contents (if any)
    std::list<T>* c;

    //Methods
public:
    /// Deallocates itself AND all of it's sons
    ~Node();
    /// Creates an empty node
    Node();
    /// Creates a node with its eight sons and a parent reference from an 9 pointer array
    Node(Node<T>** nodes);
    ///Returns the node contents
    std::list<T>* getContents(){return c;};
    ///Pushes an item into the node
    void pushItem(T item);
    ///Removes an item from the node
    void eraseItem(T item){c->erase(item);};
    ///Clears the node contents
    void clearNode(){c->clear();};
};

/**
 * @brief Container for @see Node classes
 *
 * This class allows a more convenient way of working with Octrees
 */
template <typename T> class ListOctree {
    //Attributes
private:
    int width;
    Node<T>* root;

    //Methods
public:
    ListOctree(int width);
    ~ListOctree();
    void pushItemAt(T item, int x, int y, int z);
    void eraseItemAt(T item, int x, int y, int z);
    void clearItemsAt(int x, int y, int z);
    std::list<T>* getItems();
    std::list<T>* operator() (int x, int y, int z){return(getItemsAt(x,y,z));};
    std::list<T>* getItemsAt(int x, int y, int z);
private:
    char nextNode(int x, int y, int z, int* cx, int* cy, int* cz, int width, Node<T>* n, bool createNew) throw(...);
    void _pushItemAt(T item, int x, int y, int z, int cx, int cy, int cz, int width, Node<T>* n);
    void _eraseItemAt(T item, int x, int y, int z, int cx, int cy, int cz, int width, Node<T>* n);
    void _clearItemsAt(int x, int y, int z, int cx, int cy, int cz, int width, Node<T>* n);
    std::list<T>* _getItemsAt(int x, int y, int z, int cx, int cy, int cz, int width, Node<T>* n);
    void prune(Node<T>* n);
    void addItemsToList(std::list<T>* lst, Node<T>* n);
};

/**
 * @brief Exception used internally
 * 
 * FIXME, never used, can't be used for some reason
 */
class ListOctreeException : public std::exception{
private:
    std::string msg;

public:
    ListOctreeException(){msg="ListOctreeException";};
    ListOctreeException(std::string s){msg=s;};
    const char* what(){return(msg.c_str());};
};
};//namespace
#endif
  • 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-22T22:07:14+00:00Added an answer on May 22, 2026 at 10:07 pm

    The declaration and the definition of templates should be kept in the same file (usually the .h). See the FAQ for details (it’s also technically possible to instantiate the template in a file that #includes the implementation (see this also)).

    The keyword export that was supposed to be used in the case where the two are separated, but few compilers implemented it, and it has now been removed in c++0x.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.