-3

这是我的问题错误报告:

Error   2   error LNK2019: unresolved external symbol 
"public: int __thiscall item::getSubstanceDurability(enum myEnums::MATERIAL)" (?getSubstanceDurability@item@@QAEHW4MATERIAL@myEnums@@@Z) referenced in function 
"public: virtual void __thiscall armor::setHardness(enum myEnums::MATERIAL,int)" (?setHardness@armor@@UAEXW4MATERIAL@myEnums@@H@Z)  
C:\Users\Raenir Salazar\My Projects\COMP345_Assignment2\COMP345_Assignment2\armor.obj   COMP345_Assignment2

当我试图编译时发生。这是我的代码:

项目.cpp

int getSubstanceHardness ( MATERIAL substance ) {
    switch (substance) {
    case 0:
        return 0;
        break;
    case 1:
        return 0;
        break;
    case 2:
        return 0;
        break;
    case 3:
        return 1;
        break;
    case 4:
        return 0;
        break;
    case 5:
        return 2;
        break;
    case 6:
        return 5;
        break;
    case 7:
        return 8;
        break;
    case 8:
        return 10;
        break;
    case 9:
        return 15;
        break;
    case 10:
        return 20;
        break;
    case 11:
        return 5;
        break;
    default:
        return 0;
        break;

    }
}

项目.h

int getSubstanceDurability ( MATERIAL );

盔甲。h & armour.cpp

class armor: public item {
    protected:
        int armorClass;
        int armorCheckPenalty;
        double arcaneSpellFailure;
        int maxDEXBonus;
        int speedPenalty;
        CHARACTER_ARMOR armorType;
    public:
        armor();
        armor( int, int, double, string, int, int, double, double, 
            CHARACTER_ARMOR, SIZE, MATERIAL, int /*+X*/ );

        int getArmorClass ();
        void setArmorClass ( int );
        int getArmorCheckPenalty ();
        void setArmorCheckPenalty( int );
        double getArcaneSpellFailure ();
        void setArcaneSpellFailure ( double );
        //void setArmorName ( string );
        int getMaxDEXBonus ();
        void setMaxDEXBonus ( int );
        int getspeedPenalty ();
        void setspeedPenalty ( int );
        CHARACTER_ARMOR getArmorType();
        void setArmorType( CHARACTER_ARMOR );
        void setDurability( MATERIAL, int /*AC*/, int /* +X */, SIZE );
        void setHardness( MATERIAL, int /* enhancement */ );
};

void armor::setHardness( MATERIAL substance, int enhancement ) {
    int substanceDensity; 
    substanceDensity = this->getSubstanceDurability( substance );
    int density;
    density = substanceDensity + (enhancement * 2);

    this->hardness = density;

    //this->hardness = ((this->getSubstanceDurability(substance)) + (enhancement * 2));
}

枚举.h

#ifndef ENUM_H
#define ENUM_H

namespace myEnums
{
        enum CHARACTER_CLASS
        {
            FIGHTER, CLERIC, WIZARD,
            ROGUE, DRUID, RANGER, BARD,
            SORCERER, PALADIN

        };
        enum CHARACTER_WEAPON
        {
            NOTHING, LONGSWORD, SHORTSWORD, KATANA, AMMUNITION, GRAPPLE, RAY
        };
        enum WEAPON_CATEGORY 
        {
            SIMPLE, MARTIAL, EXOTIC,
        };
        enum WEAPON_SUBCATEGORY
        {
            UNARMED, LIGHT_MELEE, ONE_HANDED_MELEE, TWO_HANDED_MELEE, RANGED
        };
        enum CHARACTER_ARMOR
        {
            UNARMORED, CHAINMAIL, PADDED
        };
        enum CHARACTER_SHIELD
        {
            NONE, BUCKLER, LIGHT_WOODEN, LIGHT_STEEL, HEADY_WOODEN,
            HEAVY_STEEL, TOWER
        };
        enum CHARACTER_RACE
        {
            HUMAN, ELF, DROW, HALFLING,
            DWARF, GNOME
        };
        enum SIZE
        {
            FINE, DIMINUTIVE, TINY, SMALL, 
            MEDIUM, LARGE, HUGE, GARGANTUAN, 
            COLOSSAL, COLOSSAL_P, COLOSSAL_PP
        };
        enum DAMAGE_TYPE
        {
                // This one is tricky, some weapons
                // Can have multiple damage types...
            BLUDGEONING, SLASHING, PIERCING
        };
        enum MATERIAL
        {
            PAPER, CLOTH, ROPE, GLASS, ICE, LEATHER, WOOD,
            STONE, METAL, MITHRAL, ADAMANTINE, SOFT_METALS
        };
        enum BAB_PROGRESSION 
        {
            HIGH, MID, LOW
        };
        enum SAVING_THROW
        {
            HIGH_SAVE, LOW_SAVE
        };
};

不知道出了什么问题,我一直在试图摆弄重载和签名,仔细检查数据类型,但没有给出实际的语法错误,据我所知,据我所知......

4

1 回答 1

1

原来我搞砸了,并且不小心在我的一个函数上使用了错误的名称,我很惊讶它竟然编译到了这么远。抱歉,我不能投票给给我答案的人。

getSubstanceHardness 被错误命名为 getSubstanceDurability。

于 2013-11-04T21:22:27.950 回答