Array list

I need help with the compiling errors please.

type.h
#ifndef arrayListType
#define arrayListType

class arrayListType
{
int main();
public:
int intlist;
void insertAt(int location, int insertItem);
void insertEnd(int insertItem);
int seqSearch(int searchItem) const;
void remove(int removeItem);
int min(int first, int last);
int max(int first, int last);
//Constructor

#endif
}

type.cpp
#include <iostream>
#include "arrayListType.h"

class arrayListTypeImp
{
public:
bool isEmpty() const;
//List is empty.

bool isFull() const;
//List is full.

int listSize() const;
//Number of elements in list.

void print() const;
//Output

bool isItemAtEqual(int location, int item) const;
//Item location

virtual void insertAt(int location, int insertItem) = 0;
//Insert item in list

virtual void insertEnd(int insertItem) = 0;

void retrieveAt(int location, int& retItem) const;
//Retrieve element from list.

void clearList();
//Remove all elements in list.

virtual int seqSearch(int searchItem) const = 0;
//Search for elements.

virtual void remove(int removeItem) = 0;

protected:
int *list;
int length;
int maxSize;
};

unordered.h
#ifndef unorderedArrayListType
#define unorderedArrayListType
#include <iostream>
#include "arrayListType.h"

class unorderedArrayListType{
int main();

public:
vector<int> intList;
void insertAt(int location, int insertItem);
void insertEnd(int insertItem);
void replaceAt(int location, int repItem);
int seqSearch(int searchItem) const;
void remove(int removeItem);
void removeAt(int location);
void removeAll();
int min(int first, int last);
int max(int first, int last);
//Constructor

#endif
}

unordered.cpp
#include <iostream>
#include "unorderedArrayListType.h"

using namespace std;


int main()
{
unorderedArrayListType intList(8);
int number;
cout << "Enter 8 Integers: ";

for (int count = 0; count < 8; count++)
{
cin >> number;
intList.insertEnd(number);
}

cout << endl;
cout << "Int List";
intList.print();
cout << endl;

cout << "The smallest number in IntList: ";
intList.print(5);
cout << endl;

}


my errors:
Error 1 error C2236: unexpected token 'class'. Did you forget a ';'?
Warning 2 warning C4094: untagged 'class' declared no symbols
Error 3 error C2143: syntax error : missing ';' before '{'
Error 4 error C2447: '{' : missing function header (old-style formal list?)
Error 5 error C3861: 'intList': identifier not found
Error 6 error C2065: 'intList' : undeclared identifier
Error 7 error C2228: left of '.insertEnd' must have class/struct/union
Error 8 error C2065: 'intList' : undeclared identifier
Error 9 error C2228: left of '.print' must have class/struct/union
Error 10 error C2065: 'intList' : undeclared identifier
Error 11 error C2228: left of '.print' must have class/struct/union
Error 12 error C2236: unexpected token 'class'. Did you forget a ';'?
Error 13 error C2143: syntax error : missing ';' before '{' 14 error C2447: '{' : missing function header (old-style formal list?)
15 IntelliSense: expected a declaration
16 IntelliSense: expected a declaration
17 IntelliSense: identifier "intList" is undefined
1. Read the first error message
2. Go to the line it is talking about
3. Read the first error message again
4. Fix it
5. Recompile the code
6. Go back to step 1
That's extremely unhelpful, if I knew how to solve the first one I wouldn't be asking for help.
If you want help, please edit your post and make sure your code is [code]between code tags[/code] - this will give it line numbers and syntax highlighting. Also, we need to know which lines those errors are referring to - just the errors themselves without line numbers is not useful.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef unorderedArrayListType
#define unorderedArrayListType
#include "arrayListType.h"

class unorderedArrayListType::public arrayListType
{
public:
	int intList;
	void insertAt(int location, int insertItem);
	void insertEnd(int insertItem);
	void replaceAt(int location, int repItem);
	void remove(int removeItem);
	void removeAt(int location);
	void removeAll();
	int min(int first, int last);
	int max(int first, int last);
	//Constructors
}
#endif 


Error 1 error C2236: unexpected token 'class'. Did you forget a ';'? Line 5
Error 2 error C2589: 'public' : illegal token on right side of '::' Line 5
Error 3 error C1903: unable to recover from previous error(s); stopping compilation Line 5
Error 1 error C2236: unexpected token 'class'. Did you forget a ';'? Line 5
As the error suggests, you probably forgot a semicolon - where? Probably near the end of your arrayListType.h file. If you can't figure out where, post the last 15 lines from it.
Error 2 error C2589: 'public' : illegal token on right side of '::' Line 5
You accidentally typed two colons instead of one colon.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include "unorderedArrayListType.h"

using namespace std;


int main()
{
	unorderedArrayListType intList(8);
	int number;
	cout << "Enter 8 Integers: ";

	for (int count = 0; count < 8; count++)
	{
		cin >> number;
		intList.insertEnd(number);
	}

	cout << endl;
	cout << "Int List";
	intList.print();
	cout << endl;

	cout << "The smallest number in IntList: ";
	intList.print(5);
	cout << endl;

}


Warning 4 warning C4094: untagged 'class' declared no symbols Line 4
Error 5 error C2143: syntax error : missing ';' before 'using' Line 4
Error 6 error C3861: 'intList': identifier not found Line 9
: 'intList' : undeclared identifier Line 16
Error 8 error C2228: left of '.insertEnd' must have class/struct/union Line 16
Error 9 error C2065: 'intList' : undeclared identifier Line 21
Error 10 error C2228: left of '.print' must have class/struct/union Line 21
Error 11 error C2065: 'intList' : undeclared identifier Line 25
Error 12 error C2228: left of '.print' must have class/struct/union Line 25
You forgot a semicolon after your unorderedArrayListType class definition.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include "unorderedArrayListType.h";

using namespace std;


int main()
{
	unorderedArrayListType; intList(8);
	int number;
	cout << "Enter 8 Integers: ";

	for (int count = 0; count < 8; count++)
	{
		cin >> number;
		intList.insertEnd(number);
	}

	cout << endl;
	cout << "Int List";
	intList.print();
	cout << endl;

	cout << "The smallest number in IntList: ";
	intList.print(5);
	cout << endl;

}


Warning 4 warning C4094: untagged 'class' declared no symbols Line 4
Error 5 error C2143: syntax error : missing ';' before 'using' Line 4
Error 6 error C3861: 'intList': identifier not found Line 9
Error 7 error C2065: 'intList' : undeclared identifier Line 16
Error 8 error C2228: left of '.insertEnd' must have class/struct/union Line 16
Error 9 error C2065: 'intList' : undeclared identifier Line 21
Error 10 error C2228: left of '.print' must have class/struct/union Line 21
Error 11 error C2065: 'intList' : undeclared identifier Line 25
Error 12 error C2228: left of '.print' must have class/struct/union Line 25
closed account (D80DSL3A)
See last line in the code below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class unorderedArrayListType::public arrayListType
{
public:
	int intList;
	void insertAt(int location, int insertItem);
	void insertEnd(int insertItem);
	void replaceAt(int location, int repItem);
	void remove(int removeItem);
	void removeAt(int location);
	void removeAll();
	int min(int first, int last);
	int max(int first, int last);
	//Constructors
};//  <- the semicolon belongs here ************* 

Remove the ; you placed after line 2 in your last post.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef ARRAYLISTTYPE_H
#define ARRAYLISTTYPE_H
#include <iostream>

class arrayListType:public unorderedArrayListType
{
public:
	int intList;
	void insertAt(int location, int insertItem);
	void insertEnd(int insertItem);
	int seqSearch(int searchItem) const;
	void remove(int removeItem);
	int min(int first, int last);
	int max(int first, int last);
	//Constructor
};
#endif 


Error 2 error C2504: 'unorderedArrayListType' : base class undefined Line 6
4 IntelliSense: not a class or struct name Line 5
closed account (D80DSL3A)
You lost this line somewhere along the way.
#include "arrayListType.h"

Please make an effort to solve your problem.
Don't just post back instantly with the next round of error messages.
These are basic errors.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>


using namespace std;

int main()
{
	unorderedArrayListType intList(8);
	int number;
	cout << "Enter 8 Integers: ";

	for (int count = 0; count < 8; count++)
	{
		cin >> number;
		intList.insertEnd(number);
	}

	cout << endl;
	cout << "Int List";
	intList.print();
	cout << endl;

	cout << "The smallest number in IntList: ";
	intList.min(5);
	cout << endl;

}


Error 4 error C2065: 'intList' : undeclared identifier Line 15
Error 6 error C2065: 'intList' : undeclared identifier Line 20
Error 8 error C2065: 'intList' : undeclared identifier Line 24
Error 1 error C2065: 'unorderedArrayListType' : undeclared identifier Line 8
Error 2 error C2146: syntax error : missing ';' before identifier 'intList' Line 8
Error 5 error C2228: left of '.insertEnd' must have class/struct/union Line 15
Error 9 error C2228: left of '.min' must have class/struct/union Line 24
Error 7 error C2228: left of '.print' must have class/struct/union Line 20
Error 3 error C3861: 'intList': identifier not found Line 8
10 IntelliSense: identifier "unorderedArrayListType" is undefined Line 8
closed account (D80DSL3A)
Why are you removing all the #include lines? This is causing the errors.
It keeps telling me no such file or directory so that's why I keep deleting them.
Topic archived. No new replies allowed.