Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Help With An error , I give up !

Reply
Thread Tools

Help With An error , I give up !

 
 
Kain0o0@gmail.com
Guest
Posts: n/a
 
      04-25-2005
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;
};

 
Reply With Quote
 
 
 
 
Srini
Guest
Posts: n/a
 
      04-25-2005
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*...

 
Reply With Quote
 
 
 
 
Kain0o0
Guest
Posts: n/a
 
      04-25-2005
I tried that but that wasnt it , its driving me insane
oh im using Visual C++ .Net

 
Reply With Quote
 
Srini
Guest
Posts: n/a
 
      04-25-2005
I don't have any problems compiling and executing your code with the
Microsoft optimising C++ compiler - ver 13.10.3077.

 
Reply With Quote
 
Kain0o0
Guest
Posts: n/a
 
      04-25-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
We dont give only job... We give you the Job Satisfaction....... Anuj Digital Photography 0 01-02-2007 06:35 PM
GIVE ME FILM OR GIVE ME DEATH l#vfgsgEg@AO1.com DVD Video 4 07-14-2005 03:10 PM
Why wouldn't this line of give give the address of the pointer? grocery_stocker C Programming 10 05-25-2005 03:05 AM
Give us 3 minutes; we give you the whole library lib Computer Support 1 02-04-2005 03:16 AM
Give us 3 minutes; we give you the whole library lib Computer Support 0 01-27-2005 07:52 AM



Advertisments