Character.h
Code: Select all
#ifndef CHARACTER_H
#define CHARACTER_H
class character
{
public:
character(string z, int a, int b, int c);
void setClass(string x);
void setHealth(int h);
void setStr(int s);
void setDex(int d);
string getClass()
{
return pClass;
}
int getHealth()
{
return health;
}
int getStr()
{
return str;
}
int getDex()
{
return dex;
}
private:
string pClass;
int health;
int str;
int dex;
};
#endif // CHARACTER_H
Code: Select all
#include <iostream>
#include <string>
#include "Character.h"
using namespace std;
character::character(string z, int a, int b, int c)
{
setClass(z);
setHealth(a);
setStr(b);
setDex(c);
}
void character::setClass(string x)
{
pClass = x;
}
void character::setHealth(int h)
{
health = h;
}
void character::setStr(int s)
{
str = s;
}
void character::setDex(int d)
{
dex = d;
}
Code: Select all
Character.h|7|error: expected ')' before 'z'|
Character.h|8|error: 'string' has not been declared|
Character.h|12|error: 'string' does not name a type|
Character.h|29|error: 'string' does not name a type|
main.cpp|8|error: redefinition of 'class Character'|
Character.h|5|error: previous definition of 'class Character'|
main.cpp||In function 'int main()':|
main.cpp|61|error: no matching function for call to 'Character::Character(const char [8], int, int, int)'|
C:\Users\Mooska\Desktop\C++ Practice\Sabra\Character.h|5|note: candidates are: Character::Character()|
Character.h|5|note: Character::Character(const Character&)|
main.cpp|62|error: 'class Character' has no member named 'getClass'|
||=== Build finished: 8 errors, 0 warnings ===|