Odd Error

K

K

I'm fairly new to c++ and have been getting the following error when I
try to execute my script (I dont get any error after compiling
though).

Error:
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::~Queue(void)" (??1Queue@@QAE@XZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: bool
__thiscall Queue::isEmpty(void)const " (?isEmpty@Queue@@QBE_NXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::dequeueback(void)" (?dequeueback@Queue@@QAEXXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: char
__thiscall Queue::getFront(void)const " (?getFront@Queue@@QBEDXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::enqueuefront(char)" (?enqueuefront@Queue@@QAEXD@Z)
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::Queue(void)" (??0Queue@@QAE@XZ)


Not sure why it is doing this. I've used this Queue.h and Queue.cpp on
other programs that function fine.

Here is the code I'm writing:

#include<iostream.h>
#include<iomanip.h>
#include "Queue.h"

struct process {
int burstTime;
int priority;
}one, two, three, four, five;

void main()
{
int selection;

one.burstTime = 10;
one.priority = 3;
two.burstTime = 1;
two.priority = 1;
three.burstTime = 2;
three.priority = 3;
four.burstTime = 1;
four.priority = 4;
five.burstTime = 5;
five.priority = 2;


cout << "Select a Scheduling Technique:\n";
cout << "1 - FCFS\n";
cout << "2 - SJF\n";
cout << "3 - Priority\n";
cout << "4 - RR\n";
cin >> selection;

if(selection == 1)
{
Queue order;

//load up the queue since we know that is is first come first serve
and we know
//the order
order.enqueuefront(3);
order.enqueuefront(two.burstTime);
order.enqueuefront(three.burstTime);
order.enqueuefront(four.burstTime);
order.enqueuefront(five.burstTime);

do
{
int tmp;
tmp = order.getFront();
order.dequeueback();

cout << "P1 ";
for(int x; x <= tmp; x++)
{
cout << "__";
}
cout << "\n";
}while(order.isEmpty());//continue while order is not empty*
}
}
 
M

Mike Wahler

K said:
I'm fairly new to c++ and have been getting the following error when I
try to execute my script (I dont get any error after compiling
though).

Error:
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::~Queue(void)" (??1Queue@@QAE@XZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: bool
__thiscall Queue::isEmpty(void)const " (?isEmpty@Queue@@QBE_NXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::dequeueback(void)" (?dequeueback@Queue@@QAEXXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: char
__thiscall Queue::getFront(void)const " (?getFront@Queue@@QBEDXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::enqueuefront(char)" (?enqueuefront@Queue@@QAEXD@Z)
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::Queue(void)" (??0Queue@@QAE@XZ)

You show the error messages, but not the code that
caused them. Where are the definitions of those
functions?
Not sure why it is doing this. I've used this Queue.h and Queue.cpp on
other programs that function fine.

Here is the code I'm writing:

#include<iostream.h>



#include "Queue.h"

We need to see this file, and the file containing
the implementations of the member functions if they're
not defined inside the class definition, and the
static members (if any).



using namespace std;
struct process {
int burstTime;
int priority;
}one, two, three, four, five;

void main()

int main()
{
int selection;

one.burstTime = 10;
one.priority = 3;
two.burstTime = 1;
two.priority = 1;
three.burstTime = 2;
three.priority = 3;
four.burstTime = 1;
four.priority = 4;
five.burstTime = 5;
five.priority = 2;


cout << "Select a Scheduling Technique:\n";
cout << "1 - FCFS\n";
cout << "2 - SJF\n";
cout << "3 - Priority\n";
cout << "4 - RR\n";
cin >> selection;

if(selection == 1)
{
Queue order;

//load up the queue since we know that is is first come first serve
and we know
//the order
order.enqueuefront(3);

Where is the definition of function 'Queue::enqueuefront()' ?
order.enqueuefront(two.burstTime);
order.enqueuefront(three.burstTime);
order.enqueuefront(four.burstTime);
order.enqueuefront(five.burstTime);

do
{
int tmp;
tmp = order.getFront();

Where is the definition of function 'Queue::getFront()' ?
order.dequeueback();

Where is the definition of function 'Queue::dequeueback()' ?
cout << "P1 ";
for(int x; x <= tmp; x++)

'x' has not been initialized or assigned a value. Both
of the expressions 'x <= tmp' and 'x++' evaluate an
uninitialized object. Undefined behavior.
{
cout << "__";
}
cout << "\n";
}while(order.isEmpty());//continue while order is not empty*

Where is the definition of function 'Queue::isEmpty()' ?

Looks like you forgot to provide the compiled Queue.cpp
to the linker.

-Mike
 
K

Karl Heinz Buchegger

K said:
I'm fairly new to c++ and have been getting the following error when I
try to execute my script (I dont get any error after compiling
though).

Error:
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::~Queue(void)" (??1Queue@@QAE@XZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: bool
__thiscall Queue::isEmpty(void)const " (?isEmpty@Queue@@QBE_NXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::dequeueback(void)" (?dequeueback@Queue@@QAEXXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: char
__thiscall Queue::getFront(void)const " (?getFront@Queue@@QBEDXZ)
hw3_v1.obj : error LNK2001: unresolved external symbol "public: void
__thiscall Queue::enqueuefront(char)" (?enqueuefront@Queue@@QAEXD@Z)
hw3_v1.obj : error LNK2001: unresolved external symbol "public:
__thiscall Queue::Queue(void)" (??0Queue@@QAE@XZ)

Not sure why it is doing this. I've used this Queue.h and Queue.cpp on
other programs that function fine.

But this time you forgot to add Queue.cpp to your project.
Or you did add a file Queue.cpp, but it does not contain
the above mentioned functions.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top