C ++ error LNK2019: unresolved external symbol "

Permalänk
Medlem

C ++ error LNK2019: unresolved external symbol "

När jag kompilerar får jag följande problem:

Elemental.obj : error LNK2019: unresolved external symbol "public: __thiscall Game::Sprite::Sprite(void)" (??0Sprite@Game@@QAE@XZ) referenced in function "public: __thiscall Elemental::Elemental(struct SDL_Surface *,int,int)" (??0Elemental@@QAE@PAUSDL_Surface@@HH@Z)

#ifndef ELEMENTAL_H #define ELEMENTAL_H #include "SDL_init.h" #include "Sprite.h" class Elemental: public Game::Sprite{ public: Elemental( SDL_Surface* img, int x, int y ); //virtual ~Sprite(); // Destructor. void tick(); // Loop which controls and updates a specific sprite object with the background objects. SDL_Surface* get_image(); double getSpeed_X(); // Will get the speed ( x ) of the object double getSpeed_Y(); // Will get the speed ( y ) of the object void set_speed( double x, double y ); // Will set the speed ( x ) of the object void move(); // Will be in main class void show(); // Will be in main class void install_sprite( std::string filename ); void delete_sprite(); protected: private: double speed_x, speed_y, x_pos, y_pos; SDL_Surface* sprite_image; SDL_Rect ebox; }; #endif

Sprite

/********************************************************* This is the root class for all gameobjects. **********************************************************/ #ifndef SPRITE_H #define SPRITE_H #include "SDL_init.h" #include <string> const int SPRITE_WIDTH = 50; const int SPRITE_HEIGHT = 56; namespace Game { class Sprite { public: Sprite(); Sprite( std::string filename ); // Constructor. Sprite::Sprite( SDL_Surface* img ); //virtual ~Sprite(); // Destructor. virtual void tick(); // Loop which controls and updates a specific sprite object with the background objects. SDL_Surface* get_image(); double getPos_X(); // Will get the x position of the object double getPos_Y(); // Will get the y position of the object double getSpeed_X(); // Will get the speed ( x ) of the object double getSpeed_Y(); // Will get the speed ( y ) of the object void move_sprite(double x, double y ); // Moves the sprite object to a specific position. void move(); void show(); void set_pos( double x, double y );// Will set the position ( x ) of the object void set_speed( double x, double y ); // Will set the speed ( x ) of the object void install_sprite( /*Sprite* installed,*/ std::string filename ); void delete_sprite( /*Sprite* deleted */); //Sprite* getInstance(); // Will create a neW sprite object and place it on the screen. protected: //Sprite() {}; private: double speed_x, speed_y, x_pos, y_pos; SDL_Surface* sprite_image; SDL_Rect box; bool jumped; }; } #endif

Permalänk
Hedersmedlem

Har du definierat Game::Sprite::Sprite(void)?

Permalänk
Medlem

var ska jag definera de ?:S

Permalänk
Hedersmedlem
Skrivet av Sandric:

var ska jag definera de ?:S

Förmodligen i sprite.cpp. Du har ett antal konstruktorer: Sprite(), Sprite( std::string filename ) och Sprite::Sprite( SDL_Surface* img ). Det verkar som att du använder Sprite() i Elemental::Elemental(struct SDL_Surface *,int,int).

Permalänk

Hur ser dina cpp filer ut?

Visa signatur

| Silverstone raven rv02 | Intel Core i7 920 @ 3.5ghz + Corsair H50 | Kingston DDR3 HyperX 1333MHz 6x2GB | XFX Radeon 6870 | ASUS P6T SE | Chieftec Super Series 750W |

Permalänk
Medlem

okej tack Det hjälpte