Help With An error , I give up !

K

Kain0o0

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;
};
 
S

Srini

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*...
 
S

Srini

I don't have any problems compiling and executing your code with the
Microsoft optimising C++ compiler - ver 13.10.3077.
 
K

Kain0o0

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top