Component.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef COMPONENT_H_
#define COMPONENT_H_

class Entity;

class Component {
private:
	Entity* parentPtr;

public:
	virtual void update() = 0;
	void setParent(Entity* mParentPtr);
};

#endif /* COMPONENT_H_ */

Component.cpp

1
2
3
4
#include "Component.h"

void Component::setParent(Entity* mParentPtr) { parentPtr = mParentPtr; }
void Component::update() { }

Entity.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef ENTITY_H_
#define ENTITY_H_

#include <vector>

class Component;

class Entity {
private:
	std::vector<Component*> componentPtrs;

public:
	void update();
};

#endif /* ENTITY_H_ */

Entity.cpp

1
2
3
4
5
6
7
8
#include <vector>

#include "Entity.h"
#include "Component.h"

void Entity::update() {
	componentPtrs[0]->update();
}

Eclipse error log (plain_text)

1
2
Description	Resource	Path	Location	Type
Method 'update' could not be resolved	Entity.cpp	/TestNewWS/src	line 7	Semantic Error