Skip to main content
gamedev.net
🔒 Locked

PROBLEM WITH CONSTRUCTOR!

Started by Juanu Sep 13, 2005 at 3:26 PM 1 replies 1k views
Original Post
Juanu
Juanu
Ok.. so... what?? we decided to start from the beginning since we didn't have that much... i started a new project so that i copuld build a better engine with classes and stuff.. but i have one problem with my Class Constructor.. Here's the code:
[SOURCE]
//Constructor
Sprite::Sprite( int ANCHO, int ALTO, int DIST, char* ARCHIVO )
{
	//Establece principalmente, los valores pasados

	//La superficie de la imagen del sprite
	sprite = IMG_Load( ARCHIVO );
	if ( sprite == NULL )
	{
		fprintf( stderr, "Hubo un error al cargar la imagen en la clase Sprite: %s\n", SDL_GetError() );
	}

	//Transparencia
	SDL_SetColorKey( sprite, SDL_SRCCOLORKEY, SDL_MapRGB( sprite->format, 255, 0, 255 ) );

	//Rect del Sprite
	rctSprite.w = ANCHO;
	rctSprite.h = ALTO;
	rctSprite.x = 1;
	rctSprite.y = 1;

	//Dirección inicial del Sprite
	dir = DERECHA;

}
[/SOURCE]
[/source] And here is where I call it:
[SOURCE]

Sprite colitas( 41, 30, 1, "/data/gfx/colitas.png" );

[/SOURCE]
[/source] And i have a problem with the lin ker... this is the output: Engine_AnimaSprite warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library Engine_AnimaSprite error LNK2019: unresolved external symbol "public: __thiscall Sprite::~Sprite(void)" (??1Sprite@@QAE@XZ) referenced in function _SDL_main Engine_AnimaSprite fatal error LNK1120: 1 unresolved externals Any Ideas please!!???? For what i see ithere's a problem with the parameters i'm passing it becauise before I didn't pass any parameters at all and it compiled and linked just fine! Thanx!
CTar
CTar
That means you haven't defined the destructor, you probably have a line like this:
virtual ~Sprite(); // Maybe without virtual

You have should also define the body for this function so add:
Sprite::~Sprite(){}

To the same place you have the constructor.
Juanu
Juanu
PROBLEM SOLVED

That's for not paying attention


Engine_AnimaSprite error LNK2019: unresolved external symbol "public: __thiscall Sprite::~Sprite(void)" (??1Sprite@@QAE@XZ) referenced in function _SDL_main


IT's ALMOST LITERALLY SAYING! YOU DON'T HAVE A DESTRUCTOR !!!!!!!!!!
MAKE ONE!!!

Right there.,. after thiscall...

LOL...

THAN YOU VERY MUCH!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.