   Using base class method c++
  For some reason the g++ wont recognise my base function called apply_surfacesprite.ccpublic:SDL_Surface* loadImage(string filename);void update(SDL_Surface *surface);void apply_surface( int x, int y,SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL );class Bullet : public spriteinport "sprite.cc"void Bullet::animation(SDL_Rectrect,SDL_Surface surface){y-=1;Sprite::apply_surface(x,y,source,surface,rect);}comes up with no matching function for call bullet::apply_surface when i specifically said it's from the base class Sprite.[Edited by - amateur programmer on June 5, 2006 8:28:13 AM]
Quote:Original post by amateur programmerclass Bulllet : public spriteQuote:Original post by amateur programmerSprite::apply_surface(x,y,source,surface,rect);Notice that public sprite in the first quote has "sprite".  in the second quote its "Sprite".  Maybe it's the capital letter?;  Yes you are using capital letter in Sprite, and you also write bullet with three l's somewhere   ;  Sorry that was a typo i didn't copy and paste the code over. But it doesn't give that error anyways. It would complain about the typo.   ;  Sprite::apply_surface is declared as void apply_surface( int x, int y,SDL_Surface* source,SDL_Surface* destination, SDL_Rect* clip = NULL );And you're trying to invoke it as Sprite::apply_surface(x,y,source,surface,rect);Where rect is of type SDL_Rect -- i.e. non-pointer type.  Change it to Sprite::apply_surface(x, y, source, surface, &rect); and it should work. [smile]   ;  tried your suggestion but it still doesn't work why? IT is picking up the function derived from base class as a candidate but it thinks it should be local.   ;  apply_surface takes five parameters: two ints, and three pointers. Bullet::animation takes a rect and surface by value, and then tries to pass them to apply_surface, even though apply_surface expects pointers.You should either change Bullet::animation() to accept pointers to SDL_Rect and SDL_Surface, or take the address of the rect and surface parameters to get pointers that are acceptable for apply_surface:Sprite::apply_surface(x, y, &source, &surface, ▭);