Here is my header file with the class definitions
Here's the header file with the classes implementationsCode:#ifndef CHARACTER_H #define CHARACTER_H class Player { private: int m_Attack; int m_Strength; int m_Armour; string m_Name; public: void SetName(); void SetAttack(int attack); void SetStrength(int strength); void SetArmour(int armour); int GetAttack(); int GetStrength(); int GetArmour(); string GetName(); }; #endif
and here's the main() fileCode:#include <iostream> #include "character.h" void Player::SetAttack(int attack) { m_Attack = attack; } void Player::SetStrength(int strength) { m_Strength = strength; } void Player::SetArmour(int armour) { m_Armour = armour; } void Player::SetName() { string temp; cout << "What is the name of your character? "; getline(cin, temp); m_Name = temp; } int Player::GetAttack() { return m_Attack; } int Player::GetStrength() { return m_Strength; } int Player::GetArmour() { return m_Armour; } string Player::GetName() { return m_Name; }
I get two errors for the class definitions file saying 'string does not name a type', have i created the class wrong or what? im baffled.Code:#include <iostream> #include "character.h" using namespace std; int main() { int temp; Player Bob; Bob.SetName(); cout << "\nWhat attack rating is your character? "; cin >> temp; Bob.SetAttack(temp); cout << "\nWhat strength rating is your character? "; cin >> temp; Bob.SetStrength(temp); cout << "\nWhat armour rating is your character? "; cin >> temp; Bob.SetArmour(temp); cout << "\n" << Bob.GetName() << " has an attack rating of " << Bob.GetAttack() << ", a strength rating of " << Bob.GetStrength() << ", and an armour rating of " << Bob.GetArmour() << "."; cin.ignore(4); return 0; }
P.S. sorry for the long post![]()



LinkBack URL
About LinkBacks



