0
#pragma once

#include "Dot.h"
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include "Platform.h"
#include "Constants.h"
#include "LTexture.h"
#include "Functions.h"
#include "Enemy.h"

class Cookie : public Enemy
{
public:

    void move(SDL_Rect r, SDL_Rect fire[fireQuantity]);
    SDL_RendererFlip getFlipType() { return flipType; }
    SDL_Rect getBody() { SDL_Rect r = { getMPosX(), getMPosY(), cookieWidth, cookieHeight }; return r; }
    void fireCookie(Platform(&p));
    
private:

    SDL_RendererFlip flipType;
    const int cookieHeight = 155;
    const int cookieWidth = 75;
    Platform* platform;
    
    
};

void Cookie::fireCookie(Platform(&p)) {
    platform = &p;
    platform->getRender();
}

declaration is incompatible with void Cookie::fireCookie( &p)

I am unsure why this is happening? Platform is included in the headers and the declaration seems to match. Can anyone help? Sorry I'm pretty new to programming.

  • Dunno if it will make a difference, but you might try `void fireCookie(Platform & p);` (i.e. without the parentheses around `&p`) as that is more common. – Jeremy Friesner Mar 22 '21 at 03:33
  • Thanks for advice. Unfortunately that didn't fix it. – Andrew Leigh Mar 22 '21 at 04:07
  • Many compilers will give you more information than what is in your question. In particular, there are usually notes telling you why the attempt to use a function is incompatible with the candidate function. Did you read the notes? Pick out the types involved (perhaps `Platform*` and `Platform&`)? Would you add the more complete error message to your question? – JaMiT Mar 22 '21 at 04:18
  • When I filled in the missing pieces, I was unable to replicate your error. Please create a [mre]. **Minimal:** the dependence on SDL appears to be unnecessary; try removing all lines that use SDL. If the stated error is still the first error when you compile, those lines are not needed for this example. Also try getting rid of the remaining header dependencies. **Reproducible:** the example code must be complete enough to attempt compilation. If you cannot get rid of `#include "Dot.h"` then `Dot.h` must be part of your example. (I think you can get rid of it, though.) – JaMiT Mar 22 '21 at 04:29

0 Answers0