Type "ArrayList" could not be resolved in eclipse

I have the following code with a header, a CPP code, and a driver code.
Here is the header code:
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
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef HUMAN_H_
#define HUMAN_H_

#include <iostream>
#include <string>

//using namespace std;

class Human {
	private:
		std::string name;
		int age;
		std::string phrase;
	public:
		Human();
		void setName(std::string n) {
			name = n;
		}
		void setAge(int a) {
			age = a;
		}
		void setPhrase(std::string p) {
			phrase = p;
		}
		std::string getName() {
			return name;
		}
		int getAge() {
			return age;
		}
		std::string getPhrase() {
			return phrase;
		}



};



#endif /* HUMAN_H_ */ 


Here is the CPP code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "Human.h"

Human::Human() {
	setName(Human::getName());
	setAge(Human::getAge());
	setPhrase(Human::getPhrase());
}

/**
void Human::setName(std::string n) {
	name = n;
}
void Human::setAge(int a) {
	age = a;
}
void Human::setPhrase(std::string p) {
	phrase = p;
}**/

' 


And here is the driver code.

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
#include "Human.h"
#include <iostream>
#include "ArrayList.h"

using namespace std;

int main() {
	ArrayList test = new ArrayList(); //the error is here
	Human h;
	std::string input;
	std::string name = "Bob";


	h.setName("Bob");
	h.setAge(20);
	h.setPhrase("Hello, I'm Bob!");

	cin << input;
	cout << h.getPhrase();
	h.setAge(h.getAge()+1);
	cout << h.getAge();
	return 0;
}



How can I fix it?
Last edited on
If we remove everything that does not seem to relate to the error, we have:
1
2
3
4
5
#include "ArrayList.h"

int main() {
	ArrayList test = new ArrayList(); //the error is here
}

Note that new returns a pointer.
Does the class ArrayList have a constructor that takes pointer to ArrayList as parameter?
L9: new ArrayList returns a pointer. ArrayList test is not a pointer.
You're trying to assign a pointer to a non-pointer item.
Try this:
 
ArrayList * test = new ArrayList;


In the future it would be helpful if you included the exact text of the error message.
I tried to add an asterisk to the variable but the error still persists.
I just found out that I just don't have the Array header file in my Eclipse. It's fixed now.
Topic archived. No new replies allowed.