<Class> does not name a type compilation error

I get this error and I don't know why...



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
#ifndef ABILITY_H
#define ABILITY_H
#include <iostream>
#include "Entity.h"

using namespace std;


class Ability
{
    public:
        Ability();
        int level;
        string name;
        int manacost;
        int healthcost;

        int damage;
        int offdamage;
        int heal;
        int offheal;
        int armordamage;



        void setStats(string n, int l, int mc, int hc, int d, int h, int ad);

};


And for the other one

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 ENTITY_H
#define ENTITY_H
#include <iostream>
#include "Entity.h"
#include "Spell.h"
#include "Item.h"
#include "Ability.h"


using namespace std;


class Entity
{
    public:
        Entity();
        int health=1;
        int mana=1;
        int level=1;
        string name="Default";
        int damage=1;
        int armor=1;
        int spellpower=1;
        int healthregen=1;
        int manaregen=1;
        int crit=1;

        Ability abilities[10];


};

#endif // ENTITY_H 


What's up with this?
Last edited on
I think I had this problem once. It's probably because you can't have two classes include each other. Entity can't include Ability while Ability includes Entity.

Also, please edit your code and use code tags - http://www.cplusplus.com/articles/jEywvCM9/

Edit: Also, why are you including Entity.h inside entity.h ? Makes no sense.

1
2
3
4
5
6
7
#ifndef ENTITY_H
#define ENTITY_H
#include <iostream>
#include "Entity.h" // remove this.
#include "Spell.h"
#include "Item.h"
#include "Ability.h" 
Last edited on
Why is Ability.h including Entity.h anyway? It does not appear to use it.
@TarikNeaj
yes, apparently that's the problem. What can I do? I need to use entity objects in Ability ones and vice versa D:
@daverave1212 If you need to use Entity in Ability and vice versa, then you should re-think your design, because it's not too good. I'm pretty sure you can implement another way of doing this the exact same thing.
Topic archived. No new replies allowed.