Witam. Od dwóch godzin próbuję zrozumieć na czym polega problem, ale już powoli dostaję siwych włosów. Błagam, niech mi ktoś powie gdzie jest błąd. Dodam że jak nie dzielę programu na pliki to wszystko działa ok.
Log kompilacji:
Kompilator: Default compiler
Building Makefile: "D:\Tomek\studia\Semestr drugi\Informatyka\Programy\Gra RPG\Makefile.win"
Wykonywanie make...
make.exe -f "D:\Tomek\studia\Semestr drugi\Informatyka\Programy\Gra RPG\Makefile.win" all
g++.exe -c gamestep.cpp -o gamestep.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"In file included from heroe.h:3,
from gamestep.cpp:4:
gamestep.h:9: error: variable or fieldplay' declared void gamestep.h:9: error: expected
;' before '(' tokengamestep.cpp:11: error: no
void Start::play(Heroe)' member function declared in class
Start'make.exe: *** [gamestep.o] Error 1
Wykonanie zakończone
Plik main:
#include <iostream>
#include <string.h>
#include "gamestep.h"
#include "heroe.h"
using namespace std;
int main()
{
Heroe nowy;
Start nowa;
nowa.play(nowy);
getchar();
return 0;
}
plik heroe.h
#ifndef heroe_h
#define heroe_h
#include "gamestep.h"
#include <list>
#include <string.h>
using namespace std;
class Heroe{
private:
string imie;
int runy, hp, zrecznosc, sila;
public:
Heroe(){};
~Heroe(){};
string getImie(){return imie;}
int getHp(){return hp;}
int getRuny(){return runy;}
int getZrecznosc(){return zrecznosc;}
int getSila(){return sila;}
void setImie(string _imie){imie = _imie;}
void setHp(int _hp){hp = _hp;}
void setRuny(int _runy){runy = _runy;}
void setSila(int _sila){sila = _sila;}
void setZrecznosc(int _zrecznosc){zrecznosc = _zrecznosc;};
};
#endif
gamestep.h
#ifndef gamestep_h
#define gamestep_h
#include "heroe.h"
#include <list>
#include <string.h>
class Start{
public:
void play(Heroe &);
};
gamestep.cpp
#include <iostream>
#include <string.h>
#include <ctime>
#include "heroe.h"
#include "gamestep.h"
using namespace std;
void Start::play(Heroe &m)
{
string _imie;
cout << "Podaj imie swojego bohatera" << endl;
cin >> _imie;
m.setImie(_imie);
srand(static_cast<int>(time(NULL)));
m.setSila(rand() % 10);
m.setHp((rand() % 100)+5);
m.setZrecznosc(rand() % 10);
}