I've been developing a text-based adventure game, in which I want to store individual items as instances of a few structs: Item
, Armor
, and Weapon
. Problem is, even though my Item
struct works, whenever I compile I am getting Armor does not name a type
and Weapon does not name a type
errors on a couple of const NoArmor/Weapon placeholders. I have checked through other threads on this topic, but none of them have proved to be applicable or useful.
Here is the code I am referring to:
#ifndef ITEMS_H_
#define ITEMS_H_
#include <string>
#include "Types.h"
using namespace std;
struct Item {
string name;
double weight;
double value;
ItemType type;
};
struct Armor {
Item base;
double armorMod;
WeaponType weakness;
WeaponType resistance;
ArmorType armorType;
};
struct Weapon {
Item base;
double damageMod;
double agilityMod;
WeaponType weaponType;
};
const Item NoItem = {"_NO_ITEM_", 0, 0, NoItemType};
const Armor NoArmor = {NoItem, 0, NoWeaponType, NoWeaponType, NoArmorType};
const Weapon NoWeapon = {NoItem, 0, 0, NoWeaponType};
#endif /* ITEMS_H_ */
EDIT: Types.h is causing the issue
Types.h:
#ifndef TYPES_H_
#define TYPES_H_
enum ItemType {
NoItemType,
Food,
Misc,
Weapon,
Armor
};
enum ArmorType {
NoArmorType,
Helmet,
Tunic,
Chestplate,
Bracers,
Gloves,
Gauntlets,
Pants,
Greaves,
Robes,
Sabatons,
Boots
};
enum WeaponType {
NoWeaponType,
Sword,
Dagger,
Hammer,
Axe,
Staff,
Bow
};
enum ClassType {
NoClassType,
Knight,
Warrior,
Thief,
Blacksmith,
Lumberjack,
Mage,
Archer
};
enum RaceType {
NoRaceType,
Human,
WoodElf,
Orc,
DarkElf,
Dragonling,
Dwarf
};
enum SpecialtyType {
NoSpecialtyType,
TwoHand,
OneHand,
Archery,
Necromancy,
Conjuration,
Destruction
};
#endif /* TYPES_H_ */
Solved: Issue was the ItemValue enum containing identical values (Weapon and Armor).