Help With An error , I give up !

Discussion in 'C++' started by Kain0o0@gmail.com, Apr 25, 2005.

  1. Guest

    Hello , thanks for any help in advance.
    Im writing some code for a c++ class and the proffessor wants us to
    implement a list template using arrays.
    I thought this would be an easy task but have been stuck with the same
    error and i cant seem to fix it. I think its the constructor but i dont
    know how to fix it .

    My error is:
    List error LNK2019: unresolved external symbol "public: __thiscall
    List<double,80>::List<double,80>(void)" (??0?$List@N$0FA@@@QAE@XZ)
    referenced in function _main

    My Code:

    ********
    list.h
    ********
    template <class DATA, int MAX_LIST_SIZE>
    class List
    // Stores a list of DATA with the member functions shown below.
    // Positions in the list are numbered starting with 1 (not 0).
    {
    public:
    // constuctors -- no destructor needed
    List();
    List(const List<DATA,MAX_LIST_SIZE>& original);

    // accessors

    bool isEmpty() const;
    bool isFull() const;
    int getLength() const { return _firstOpen; }
    DATA retrieve (int position, bool& success) const;

    // mutators
    void insert (int position, DATA newItem, bool& success);
    // inserts newItem into specifice position
    // --- except that, if position is past the end of the list,
    // inserts at the end of the list
    void remove(int position, bool& success);

    private:
    DATA _element[MAX_LIST_SIZE];
    // For space efficiency, I'll store the 1st element
    // in position 0; the second, in position 1, etc.
    int _firstOpen;
    };

    *********
    list.h
    *********
    #include "list.h"


    template <class DATA, int MAX_LIST_SIZE>
    List<DATA,MAX_LIST_SIZE>::List()
    {
    _firstOpen=0;
    DATA _element[MAX_LIST_SIZE];
    }

    /*template <class DATA, int MAX_LIST_SIZE>
    List<DATA,MAX_LIST_SIZE>::List(const List<DATA,MAX_LIST_SIZE>&
    original)
    {
    DATA=original.DATA;
    MAX_LIST_SIZE=original.MAX_LIST_SIZE;
    //DATA _element[MAX_LIST_SIZE];
    }
    */
    template <class DATA, int MAX_LIST_SIZE>
    bool List<DATA,MAX_LIST_SIZE>::isEmpty() const
    {
    return _firstOpen==0;
    }

    template <class DATA, int MAX_LIST_SIZE>
    bool List<DATA,MAX_LIST_SIZE>::isFull() const
    {
    return _firstOpen==MAX_LIST_SIZE;
    }

    template <class DATA, int MAX_LIST_SIZE>
    void List<DATA,MAX_LIST_SIZE>::insert(int position, DATA newItem, bool&
    success)
    {
    if(position > MAX_LIST_SIZE)
    {
    DATA _element[MAX_LIST_SIZE]=newItem;
    }
    else
    {
    DATA _element[position]=newItem;
    }
    }

    template <class DATA, int MAX_LIST_SIZE>
    void List<DATA,MAX_LIST_SIZE>::remove(int position, bool& success)
    {
    DATA _element[position]="deleted";
    }

    template <class DATA, int MAX_LIST_SIZE>
    DATA List<DATA,MAX_LIST_SIZE>::retrieve (int position, bool& success)
    const
    {
    return DATA _element[position];
    }

    ********
    listTest
    ********
    #include "list.h"
    #include <iostream>

    using namespace std;


    int main()
    {
    List<double,80> test;
    return 0;
    };
     
    , Apr 25, 2005
    #1
    1. Advertising

  2. Srini Guest

    The class is a template class - to instantiate a particular instance of
    a template class, the whole class definition must be visible in the
    particular translation unit. In listTest, you need to include list.cpp
    in order to resolve your problem.

    Regards,
    Srini

    Don't make someone a *priority* who only makes you an *option*...
     
    Srini, Apr 25, 2005
    #2
    1. Advertising

  3. Kain0o0 Guest

    I tried that but that wasnt it , its driving me insane
    oh im using Visual C++ .Net
     
    Kain0o0, Apr 25, 2005
    #3
  4. Srini Guest

    I don't have any problems compiling and executing your code with the
    Microsoft optimising C++ compiler - ver 13.10.3077.
     
    Srini, Apr 25, 2005
    #4
  5. Kain0o0 Guest

    Really?!
    I gave up on the error and will just attempt to ask the proffessor
    tommorow , im not sure if the error I'm getting is specific to .Net ,
    i've seen it do crazy things sometimes!

    thanks for the input though , and if anyone else can shed some light on
    this issue please do so
     
    Kain0o0, Apr 25, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. biteside
    Replies:
    0
    Views:
    4,387
    biteside
    Oct 13, 2003
  2. Ken Cooper
    Replies:
    1
    Views:
    2,606
    Eric Lawrence [MSFT]
    Feb 20, 2004
  3. =?Utf-8?B?QW5hbWlrYQ==?=

    URgent!!!!!!!!!! Macros in Excel give aan error

    =?Utf-8?B?QW5hbWlrYQ==?=, Apr 6, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    1,721
    Raymond Lewallen
    Apr 6, 2004
  4. COHENMARVIN

    CustomValidator doesn't give error message

    COHENMARVIN, Aug 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,466
    Peter Blum
    Aug 5, 2005
  5. grocery_stocker
    Replies:
    10
    Views:
    642
    Keith Thompson
    May 25, 2005
Loading...

Share This Page