我想要什么时候运行这个函数(Monster.cpp)
void Monster::addWeapon(typeOfWeapon selection){
cout<<myWeaponSelection<<endl; //out puts correctly.
myWeaponSelection[0].getWeapon(selection); //gives error
}
它会运行这个函数(weapon.cpp)
void getWeapon(typeOfWeapon myWeaponSelection)
{
cout<<"you got weapon!"<<myWeaponSelection<<endl
}
错误:monster.cpp(126):错误 C2228:'.getWeapon' 左侧必须有类/结构/联合
怪物.h
#ifndef MONSTER
#define MONSTER
#include <string>
using namespace std;
enum typeOfMonster {dog,wolf,bear,goat,human,god,snail,elephant,wayven,bird,worm,kid,boy,ent,superman};
class Monster
{
public:
Monster();
~Monster(){}
typeOfWeapon myWeaponSelection[2];
void addWeapon(typeOfWeapon weaponName);
};
#endif
武器.h
#ifndef WEAPON
#define WEAPON
#include <string>
using namespace std;
enum typeOfWeapon {bark,howel,eat,ram,shoot,smite,slime,stomp,peck,swarm,dig,bow,slingshot,kick,beem, //wp 1
bite,charm,claw,naw,burn,lighingstrike,heal,smack,lazers,poop,posion,superkick,punch,tackel,freeze};//wp 2
class Weapon
{
public:
Weapon();
~Weapon(){}
typeOfWeapon myWeaponSelection;
void getWeapon(typeOfWeapon myWeaponSelection,int whichWeapon);
};
#endif
怎么修?