Przepraszam za temat:
Pliki:
main.cpp:
#include <iostream>
#include <cstring>
#include "character.hpp"
#include "charactercreate.hpp"
using namespace std;
hero player;
int main()
{
player.money = 100;
player.live = 100;
cout << "Give name of your hero:\n";
cin >> player.name;//give name
cout << "First you must create your character.\n\n";
create(& player);
return 0;
}
klasa character.hpp:
#ifndef CHARACTER_HPP_INCLUDED
#define CHARACTER_HPP_INCLUDED
#include <iostream>
using namespace std;
class hero
{
//private
public:
string name, whoiam;
int live,
damage,
armor,
money,
who; //wizard,warrior...
};
#endif // CHARACTER_HPP_INCLUDED
plik charactercreate.hpp:
#ifndef CHARACTERCREATE_HPP_INCLUDED
#define CHARACTERCREATE_HPP_INCLUDED
#include <iostream>
#include "character.hpp"
#include "charactercreate.cpp"
extern hero player;
void create(hero * player);
#endif // CHARACTERCREATE_HPP_INCLUDED
plik createcharacter.cpp:
#include <iostream>
#include "character.hpp"
#include "charactercreate.hpp"
extern hero player;
using namespace std;
void create(hero * player)
{
int whoIsPlayer;
cout << "Who do you want to be?\n1.Warrior\n2.Wizard\n3.Archer";
cin >> whoIsPlayer;
player.who=whoIsPlayer;
{//local->define player.damage and player.armor
if(whoIsPlayer=1)
{
player.damage=11;
player.armor=10;
player.whoiam="Warrior";
}
else if(whoIsPlayer=2)
{
player.damage=15;
player.armor=6;
player.whoiam="Wizard";
}
else if(whoIsPlayer=3)
{
player.damage=14;
player.armor=7;
player.whoiam="Archer";
}
}//end of create definitions
cout << "#########CREATE#########\n";
cout << "# #\r#Your name: " << player.name << endl;
cout << "# #\r#You are " << player.whoiam << endl;
cout << "# #\r#Your attack = " << player.damage << endl;
cout << "# #\r#Your armor = " << player.armor <<endl;
cout << "########################\n";
}
A oto moja lista błędów:
||=== RPG1, Debug ===|
C:\Cpp\RPG1\RPG1\charactercreate.cpp||In function 'void create(hero*)':|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|11|error: request for member 'who' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|13|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|15|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|16|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|17|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|19|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|21|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|22|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|23|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|25|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|27|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|28|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|29|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|34|error: request for member 'name' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|35|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|36|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|37|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp||In function 'void create(hero*)':|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|6|error: redefinition of 'void create(hero*)'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|6|error: 'void create(hero*)' previously defined here|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|11|error: request for member 'who' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|13|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|15|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|16|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|17|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|19|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|21|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|22|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|23|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|25|warning: suggest parentheses around assignment used as truth value|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|27|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|28|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|29|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|34|error: request for member 'name' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|35|error: request for member 'whoiam' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|36|error: request for member 'damage' in 'player', which is of non-class type 'hero*'|
C:\Cpp\RPG1\RPG1\charactercreate.cpp|37|error: request for member 'armor' in 'player', which is of non-class type 'hero*'|
||=== Build finished: 30 errors, 6 warnings ===|
**Jestem początkujący, proszę o wyrozumiałość :)