Thread: Instantiating a template class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    6

    Question Instantiating a template class

    Heeeelllooo... !


    Okay, I have this pretty weird problem, or so I think

    I have a CDLDAList Class, its declaration is:

    Code:
    template <class Type> class CDLDAList
    {
    private:
        /**
         * @brief Friend class declaration for CDLIterator
         */
        template <class Type> friend class CDLIterator;
    //..... declaration of private stuff
    public:
    
        /**
         * @brief    Default constructor
         * @pre        true
         * @post    Empty list constructed
         */
        CDLDAList<Type>();
    //.... rest of public thingies
    }
    and its constructor is defined as follows:

    Code:
    template <class Type> CDLDAList<Type>::CDLDAList<Type>()
    {
        nMaxIterators=100;
        nIterators=0;
        pHead=NULL;
        pTail=NULL;
        pIterators=new CDLIterator<Type>[nDeltaIterators];
        nItems=0;
    }
    now I have another class which has an attribute of type CDLDAList<int>, like this:

    Code:
    class CFacade
    {
    private:
        /**
         * @brief    List of Integers
         */
        CDLDAList<int> lList;
    //rest of class declaration
    }
    Now, trying to compile this, with two different compilers, gives different errors

    With Visual Studio .NET 2003 it gives me linker errors saying none of CDLDAList<int>'s member functions I'm using could be found by the linker

    Something among this line

    Quote Originally Posted by Visual Studio
    TallerListas1_09 error LNK2019: unresolved external symbol "public: __thiscall CDLDAList<int>::~CDLDAList<int>(void)" (??1?$CDLDAList@H@@QAE@XZ) referenced in function "public: __thiscall CFacade::~CFacade(void)" (??1CFacade@@QAE@XZ)

    TallerListas1_09 error LNK2019: unresolved external symbol "public: bool __thiscall CDLDAList<int>::eraseItem(class CDLIterator<int>)" (?eraseItem@?$CDLDAList@H@@QAE_NV?$CDLIterator@H@@ @Z) referenced in function "public: enum Result __thiscall CFacade::srvEraseItem(class CDLIterator<int>)" (?srvEraseItem@CFacade@@QAE?AW4Result@@V?$CDLItera tor@H@@@Z)
    and so on

    --------------------------

    Borland C++Builder 6.0 "stands" where I will make the text bold:

    template <class Type> CDLDAList<Type>::CDLDAList<Type>()
    {
    //constructor code here
    }

    saying

    Quote Originally Posted by Borland
    [C++ Error] DLDAList.cpp(14): E2040 Declaration terminated incorrectly
    Now, if I change it so it says template <class Type> CDLDAList<Type>::CDLDAList() instead, it will give me a linker error, just like MSVS.NET's, saying there's an unresolved external ( CDLDAList<int>::CDLDAList<int>() )

    I dunno if I'm not following proper syntax or what, but I'm pretty confused about what to do and I think I'm doing it how it's supposed to be done... I dunno


    Miguel Andrés
    Last edited by NullS; 02-23-2005 at 12:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  2. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  3. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  4. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  5. Operator overloading in template classes
    By moejams in forum C++ Programming
    Replies: 5
    Last Post: 07-21-2003, 05:16 PM