I'm trying to create a program that can perform some functions on both ordered lists and unordered lists, however when I compile I'm getting some errors that I am having trouble figuring out. I have a total of 7 files. A ListType.h and ListType.cpp for my base class, then derived classes of OListType.h and OListType.cpp for ordered lists and UListType.h and UListType.cpp for unordered lists. Then my main program which is named Program04 per directions from my instructor. I'm assuming if I can fix the errors in line 4 of OListType.cpp and UListType.cpp that the errors in the main program will go away. Can anybody point me in the right direction? Thanks for any help you guys can offer
Here are the errors I'm getting:
OListType.cpp:4:22: error: ISO C++ forbids declaration of "OlistType" with no type
OListType.cpp:4:22: error: no "int OListType::OlistType()" member function declared in class "OListType"
Program04.cpp: In function "int main()":
Program04.cpp:56:9: error: "IntUList" was not declared in this scope
Program04.cpp:59:9: error: "IntOList" was not declared in this scope
UListType.cpp:4:22: error: ISO C++ forbids declaration of "UlistType" with no type
UListType.cpp:4:22: error: no "int UListType::UlistType()" member function declared in class "UListType"
Here's the OListType.cpp code that it states the error is in:
Code:
#include "OListType.h"
#include <iostream>
OListType::OlistType(){
}
OListType::OListType(size_t newsize):ListType(newsize){
}
OListType::~OListType(){
}
void OListType::insert(int item){
if(!this->full()){
int loc = 0;
while((loc < this->count) && (this->list[loc] < item))
++loc;
for (int i = this->count; i > loc; --i)
this->list[i] = this->list[i-1];
this->list[loc] = item;
++this->count;
}
else
std::cerr << "Cannot insert into a full list. \n";
}
void OListType::erase(int item){
if(!this->empty()){
int loc = 0;
while((loc < this->count) && (this->list[loc] != item))
++loc;
if(loc < this->count){
for(int i = loc; i< this->count; ++i) {
this->list[i] = this->list[i+1];
}
--this->count;
}
}
else
std::cerr << "The list is already empty. \n";
}
And here is the UListType.cpp:
Code:
#include "UListType.h"
#include <iostream>
UListType::UlistType(){
}
UListType::UListType(size_t newsize):ListType(newsize){
}
UListType::~UListType(){
}
void UListType::insert(int item){
if(!this->full()){
this->list[this->count]=item;
this->count++;
}
else
std::cerr << "Cannot insert into a full list.";
}
void UListType::erase(int item){
if(!this->empty()){
int loc=0;
while ((loc < this->count) && (this->list[loc]!=item))
++loc;
if (loc < this->count){
this->list[loc] = this->list[count-1];
--this->count;
}
}
else
std::cerr << "The list is already empty. \n";
}