Class, trying to get my .cpp file to work

This is the header file of Unit

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include<iostream>
#include<string>
#include<vector>
#include"Weapon.h"
#include"Item.h"
#include"Armor.h"
#include"Materia.h"
#include"Accessory.h"
#include"Skill.h"
using namespace std;

#pragma once
class Unit
{
public:
	Unit(string name);
	~Unit();

	string getName();
	int getLevel();
	int getHP();
	int getMP();
	int getXP();
	int getHPMax();
	int getMPMax();
	int getCurrentXP();
	void addXP(int XP);
	int getNextXP();

	void takeDamage(int damage);

	Weapon getWeapon();
	void equipWeapon(Weapon weapon);
	Armor getArmor();
	void equipArmor(Armor armor);
	Accessory getAccessory();
	void equipAccessorry(Accessory accessory);

	void addItem(Item item);
	void useItem(Item item);

	void useSkill(Skill skill);

	int getStrength();
	void getStrength(int Strength);
	int getDexterity();
	int getMagic();
	int getVitality();
	int getSpirit();
	int getLuck();

	int getAttack();
	float getAttackPercentage();
	int getDefense();
	float getDefensePercentage();
	int MagicAttack();
	int MagicDefense();
	float getMagicDefensePercentage();

private:
	string mName;
	int mLevel;
	int mHP;
	int mMP;
	int mXP;
	int mHPMax;
	int mMPMax;
	int mXPMax;
	int mCurrentXP;
	int mNextXP;

	Weapon mweapon;
	Armor marmor;
	Accessory maccessory;

	vector<Item> mItems;

	vector<Skill> mSkills;

	int mStrength;
	int mDexterity;
	int mVitality;
	int mMagic;
	int mSpirit;
	int mLuck;

	int mAttack;
	float mAttackPercentage;
	int mDefense;
	float mDefensePercentage;
	int mMagicAttack;
	int mMagicDefense;
	float mMagicDefensePercentage;

	void levelUp();
};


////////////////////////////////////////////////////////////////////////////////

This is the .cpp file for Unit that should work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<string>
#include "Unit.h"
using namespace std;


Unit::Unit(string name,int HP, int MP, int XP)
{
	mName = name;
	mHP = HP;
	mMP = MP;
	mXP = XP;
}

string Unit::getName()
{
	return "Heyoo, my name is " + mName;
}

Unit::~Unit()
{

}
Last edited on
that should work.

It would help if you told us the actual issue.

You realise you've only one function implementation in your cpp, but have declared a lot more in your class definition?

edit: can you use code tags please? cheers.
Last edited on
Topic archived. No new replies allowed.