Problem z linkowaniem
Ostatnio zmodyfikowano 2012-05-28 18:38
Virpi Temat założony przez niniejszego użytkownika |
Problem z linkowaniem » 2012-05-21 23:13:37 Może zacznęod kodu programu, a chyba muszę wkleić wszystkie pliki *.h żeby było widać o co chodzi:
#ifndef CAKWARIUM_H #define CAKWARIUM_H
#include <vector> #include <iostream> #include <cassert> #include <cmath>
#include "CElement_gry.h" #include "CElement_zywy.h" #include "CElement_ruchomy.h" #include "CSlimak.h" #include "CKamien.h" #include "CWodorost.h" #include "CRybka.h" #include "CKarma.h" #include <SFML/Graphics.hpp>
class CAkwarium { public: CAkwarium(); virtual ~CAkwarium(); void ch_water_lvl( sf::Event key ); int r_water_lvl(); void add_item( sf::Event key ); void delete_item( int i ); void play( sf::Event action, const sf::Input & wejscie, CAkwarium * ); Tstruct find_seaweed( int x, int y, int z ); Tstruct find_food( int x, int y, int z ); CElement_gry * wsk; std::vector < CElement_gry *> obj_list; protected: private: int water_lvl; };
#endif
#ifndef CELEMENT_GRY_H #define CELEMENT_GRY_H
#include <SFML/Graphics.hpp>
struct Tstruct { int x, y, z; };
class CElement_gry { public: CElement_gry(); virtual ~CElement_gry(); Tstruct read_poz(); Tstruct read_hitbox(); protected: Tstruct poz, hitbox; private: };
#endif
#ifndef CSLIMAK_H #define CSLIMAK_H
#include "CElement_zywy.h" #include "CElement_ruchomy.h"
class CAkwarium;
class CSlimak : public CElement_ruchomy , public CElement_zywy { public: CSlimak( int ); virtual ~CSlimak(); void move( sf::Event key, CAkwarium *, int water_lvl ); void eat_food( CAkwarium *& ); protected: private: void move_manual( sf::Event key, int water_lvl ); };
#endif
#ifndef CKAMIEN_H #define CKAMIEN_H
#include "CAkwarium.h" #include "CElement_zywy.h"
class CAkwarium;
class CKamien : public CElement_gry { public: CKamien(); virtual ~CKamien(); void destroy_alive( CAkwarium * & m_akw ); protected: private: };
#endif
#ifndef CELEMENT_ZYWY_H #define CELEMENT_ZYWY_H
class CElement_zywy { public: CElement_zywy(); virtual ~CElement_zywy(); void grow(); void make_older(); protected: int age; private: };
#endif
#ifndef CWODOROST_H #define CWODOROST_H
#include "CElement_gry.h" #include "CElement_zywy.h"
class CWodorost : public CElement_gry , public CElement_zywy { public: CWodorost(); virtual ~CWodorost(); void bite(); protected: private: };
#endif
#ifndef CRYBKA_H #define CRYBKA_H
#include "CElement_ruchomy.h" #include "CElement_zywy.h" #include "CAkwarium.h"
class CRybka : public CElement_ruchomy , public CElement_zywy { public: CRybka( int water_lvl ); virtual ~CRybka(); void move( sf::Event key, CAkwarium *, int water_lvl ); void eat_food( CAkwarium *& ); protected: private: void move_manual( sf::Event key, int water_lvl ); };
#endif
#ifndef CKARMA_H #define CKARMA_H
#include "CElement_gry.h" #include "CAkwarium.h"
class CAkwarium;
class CKarma : public CElement_gry { public: CKarma( int ); virtual ~CKarma(); void eat( CAkwarium *&, int ); protected: private: };
#endif
#ifndef CELEMENT_RUCHOMY_H #define CELEMENT_RUCHOMY_H
#include "CAkwarium.h" #include <SFML/Graphics.hpp>
class CAkwarium;
class CElement_ruchomy : public CElement_gry { public: CElement_ruchomy(); virtual ~CElement_ruchomy(); virtual void move( sf::Event key, CAkwarium *, int water_lvl ) = 0; virtual void eat_food( CAkwarium *& ) = 0; void change_active( const sf::Input & wejscie ); void change_speed(); void stop( CAkwarium * ); void make_hungry(); void die(); void move_auto( Tstruct ); protected: bool active; bool hungry; int speed; Tstruct action; private: virtual void move_manual( sf::Event key, int water_lvl ) = 0; };
#endif
Mianowicie po dodaniu funkcji void stop( CAkwarium * ); w klasie CElement_ruchomy otrzymuję błędy:
error: expected class-name before ',' token w plikach CSlimak i CRybka. Nie rozpoznaje mi tam klasy CElement_ruchomy. Nie pojmuję dlaczego. Może gdzieś przesadziłem z liczbą dołączanych plików nagłówkowych? Ale zmieniałem je na wiele sposobów i nie udało mi się tego skompilować ;/ |
|
kubawal |
» 2012-05-28 17:11:55 Masz za dużo nagłówków i się w nich gubisz.Wsadź klasy jednego rodzaju do jednych plików nagłówkowych |
|
DejaVu |
» 2012-05-28 18:38:24 W plikach:
dołącz plik:
#include "CElement_ruchomy.h"
|
|
« 1 » |