I am trying to implement a queue based on a Linked List that I had to write previously. It is templated and for some reason I am getting the following error using g++ when I compile:
g++ LinkedQueueMain.cpp -o LinkedQueueMain
/tmp/ccqwStpK.o: In function `main':
LinkedQueueMain.cpp:(.text+0x2ee): undefined reference to `LinkedQueue<char>::operator=(LinkedQueue<char> const&)'
collect2: ld returned 1 exit status
It is saying undefined reference however I have declared and defined it so I cant figure out what the problem is.
This is my class declaration and definition: // LinkedQueue.h
template<typename T>
class LinkedQueue {
private:
LinkedList<T> ll;
public:
// user-defined exceptions
class QueueEmptyException : public RuntimeException {
public:
QueueEmptyException() : RuntimeException("Access to an empty queue") {}
};
Our professor gave us a skeleton of the code and it already had the return statement in it so I didn't change it. The LinkedList = operator overload returns a pointer as well.
Well the definition is within the class and classes can access their own private data members so ya it should work. I tried putting it in the public section just to check and it did the same thing. As to your example thats basically the same thing that im trying to do. I don't see why mine doesnt work.
Well the definition is within the class and classes can access their own private data members so ya it should work. I tried putting it in the public section just to check and it did the same thing. As to your example thats basically the same thing that im trying to do. I don't see why mine doesnt work.
I'm not sure about this.
Function can access IT'S own members (this->memb1; this->memb2;)
But I'm really not sure about accessing other instance of same type...
I'm not sure about this.
Function can access IT'S own members (this->memb1; this->memb2;)
But I'm really not sure about accessing other instance of same type...
Maybe your problem is in something else...
I have done something very similar to that previously so I am pretty sure thats not the problem.
BTW Thanks to everyone thats been trying to help. This is getting really frustrating.
I think its zipped now thats the first time I have done that. I am sorry its been so long. I had an emergency that kept me from the computer for a couple days. Im back now and still annoyed by this error.
o crap i must have zipped an older version. I had had that and it still didn't work. I just ended up redoing the entire header and now it works so thank you to everyone who helped