Saying Class does not exist?


Enemies.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<SDL.h>
#include"Labels.h"

class Enemies
{
protected:
	int health;
	int strength;
	int speed;
	virtual void draw() = 0;
	virtual void RandSpawn() = 0;
	virtual void Drop() = 0;

}


fodder.h, inheriting from Enemies.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
#include"Enemies.h"

class fodder:public Enemies
{
public:

	fodder(void);
	~fodder(void);
	void draw();
	void RandSpawn();
	void Drop();
private:
	int* health;
	int* strength;
	int* speed;
	float targetXPos;// positions used for targe.
	float targetYPos;
	float targetXSize;
	float targetYSize;
};


fodder.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "fodder.h"


fodder::fodder(void)
{
	*health = 3;
	*strength = 3;
	*speed = 7;
	targetXPos = 0.0f;
	targetYPos = 0.0f;
	targetXSize = 0.1f;
	targetYSize = 0.1f;
	targetXPos = (float)rand()/RAND_MAX - 0.75f;
	targetYPos = (float)rand()/RAND_MAX - 0.75f;

}


fodder::~fodder(void)
{
}


void fodder::draw()
{
	glColor3f(0.0,1.0,0.0);
	glBegin(GL_POLYGON);
	glVertex3f (targetXPos, targetYPos, 0.0); // first corner
	glVertex3f (targetXPos+targetXSize, targetYPos, 0.0); // second corner
	glVertex3f (targetXPos+targetXSize, targetYPos+targetYSize, 0.0); // third corner
	glVertex3f (targetXPos, targetYPos+targetYSize, 0.0); // fourth corner
	glEnd();
	Labels* TargetLabel = new Labels;
	TargetLabel->textToTexture("Target");
	TargetLabel->DrawString(targetXPos+(targetXSize/2.0f), targetYPos+targetYSize);
}

	void fodder::Drop()
	{

	}

	void fodder::RandSpawn()
	{

	}



My program is giving me a load of errors, but there all basically because it says the fodder class does not exist. It says this, with some other errors, but the others are just because thats not recognising its a class. is it because I've not actually made a fodder object yet?

Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.cpp 5
Error 7 error C2653: 'fodder' : is not a class or namespace name c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.cpp 4
Error 19 error C2653: 'fodder' : is not a class or namespace name c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.cpp 19
Error 6 error C2447: '{' : missing function header (old-style formal list?) c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.h 5
Error 1 error C2236: unexpected 'class' 'fodder'. Did you forget a ';'? c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.h 4
Error 5 error C2143: syntax error : missing ';' before '{' c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.h 5
Error 2 error C2143: syntax error : missing ';' before ':' c:\users\ryan\desktop\ryancook-games-engine-desing-repo.-f95769da919a\fodder.h 4
You're missing a semi-colon after Enemies declaration. (Line 14 of Enemies.h)
wow. feel like such an idiot, had me stumped for a good hour and a half!!
Cheers man, at least it was simple, was pretty sure it was, just couldn't see it for looking at it.
It happens
Topic archived. No new replies allowed.