Why does 'Human' not name a type?

It was working perfectly fine until I added the People class and the People.cpp in my eclipse file. The error is in the three lines with the Human types in People.h. Here are the files.

People.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef SRC_PEOPLE_H_
#define SRC_PEOPLE_H_
#include "Human.h"

class People {
	private:
		int size;
		int position;
	public:
		People();
		People(int size, int position);
		void setSize(int size);
		void setPosition(int position);
		int getSize();
		int getPosition();
		Human search(std::string name);
		Human insert(Human newHuman);
		Human humans[];
};



#endif /* SRC_PEOPLE_H_ */ 


Human.h:
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
#ifndef HUMAN_H_
#define HUMAN_H_

//#include <iostream>
#include <string>
#include "People.h"

//using namespace std;

class Human {
	private:
		std::string name;
		int age;
		std::string phrase;
	public:
		Human(); //default constructor
		Human(std::string name, int age, std::string phrase); //constructor with three variables
		//setters
		void setName(std::string n);
		void setAge(int a);
		void setPhrase(std::string p);
		//getters
		std::string getName();
		int getAge();
		std::string getPhrase(); //print phrase


};



#endif /* HUMAN_H_ */


Human.cpp:

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
#include "Human.h"
#include "People.h"
using namespace std;

Human::Human() {//default constructor...
	name = "", age = 0, phrase = "";
}
Human::Human(std::string name, int age, std::string phrase) {
	setName(name);
	setAge(age);
	setPhrase(phrase);
}
//setters
void Human::setName(std::string n) {
	name = n;
}
void Human::setAge(int a) {
	age = a;
}
void Human::setPhrase(std::string p) {
	phrase = p;
}
//getters
std::string Human::getName() {
	return name;
}
int Human::getAge() {
	return age;
}
std::string Human::getPhrase() {
	return phrase;
}


Driver.cpp:

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

using namespace std;

int main() {
//ArrayList can have add, remove and get
	ArrayList <std::string> list;
	//Human h;
	std::string input;
	Human *humanList = new Human[4];
	humanList[0]=Human("Groot", 100, "I am Groot");
	humanList[1]=Human("Bob", 20, "Hello");
	humanList[2]=Human("asdsg", 4, "...");

	while(input != "stop") { //when user says "stop" then the program exits
		cout << "Input a string or stop to end ";
		cin >> input;
    	list.add(input);
		cout << "Phrase: " << humanList[0].getPhrase() << endl; //person says their phrase
		list.add(humanList[0].getPhrase());
		humanList[0].setAge(humanList[0].getAge()+1); //their age increment by one
		cout << "Age: " << humanList[0].getAge() << endl;
		cin >> input;
		humanList[0].setAge(humanList[0].getAge()+1); //their age increment by one
		cout << "Age: " << humanList[0].getAge() << endl;
	}

	return 0;
}


People.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "Human.h"
#include "People.h"
using namespace std;

People::People() {
	size = 0; position = 0;
}

People::People(int size, int position) {
	setSize(size);
	setPosition(position);
}


How do I fix this?
Last edited on
You have unnecessary circular dependencies.

"Human.h" includes "People.h" and "People.h" includes "Human.h"

So remove line 6 in Human.h
It's fixed now. Thanks!
Topic archived. No new replies allowed.