Hey guys, I'm trying to put together a queue program. I've been working off and on with this for weeks and have had absolutely no luck. I've stripped the code down to just it's basic functions and data members, so right now all that exists are constructors and a function that creates new class objects each time a new piece of data is passed to it. Just about all of this code is lifted directly from the assignment sheet that my professor gave me. I can't for the life of me get it to compile. Below is my code, followed by the compiler errors:
In main, you're passing 3 character string literals which are implicitly constchar *
Your declaration of queue::addItem says it takes a char *
The compiler is giving you a warning because you're trying to pass a const char * to a char *. Change addItem to take a const char *. You'll need to change queueItem's constructor also.
|||=== fifo, Debug ===|
C:\Users\Loot\Desktop\Program Dump\fifo\queue.h|15|error: ISO C++ forbids declaration of 'queueItem' with no type|
C:\Users\Loot\Desktop\Program Dump\fifo\queue.h|15|error: expected ';' before '*' token|
C:\Users\Loot\Desktop\Program Dump\fifo\queue.h|16|error: ISO C++ forbids declaration of 'queueItem' with no type|
C:\Users\Loot\Desktop\Program Dump\fifo\queue.h|16|error: expected ';' before '*' token|
C:\Users\Loot\Desktop\Program Dump\fifo\queueItem.cpp||In constructor 'queueItem::queueItem(const char*, int)':|
C:\Users\Loot\Desktop\Program Dump\fifo\queueItem.cpp|9|error: 'strncpy' was not declared in this scope|
C:\Users\Loot\Desktop\Program Dump\fifo\queueItem.cpp||In function 'void setNext(queueItem*)':|
C:\Users\Loot\Desktop\Program Dump\fifo\queueItem.cpp|15|error: 'pNext' was not declared in this scope|
||=== Build finished: 6 errors, 0 warnings ===|
It seems to be taking issue with the queueItem pointers.
In queue.h you include queueitem.h where you include queue.h where you include queueitem.h where you include queue.h where you include queueitem.h.... (that's not quite how it works, but if you have files that include each other, it's a problem.)
In queueItem.h you don't need to include queue.h at all.
In queue.h you could get away with a forward declaration of : class queueItem; at file scope.