As far as I can see the code for this class works yet it will not compile and is throwing the error mentioned in the title. Below is the header file.

This is using the SDL standard libraries.

texture2D.h

#ifndef TEXTURE2D_H
#define TEXTURE2D_H

#include <SDL.h>
#include <string>
#include "Commons.h"

using namespace::std;

class Texture2D
{
    SDL_Renderer* mRenderer;
    SDL_Texture* mTexture;

    int mWidth;
    int mHeight;

public:
    Texture2D(SDL_Renderer* renderer);
    ~Texture2D();

    bool LoadFromFile(string path);
    void Free();
    void Render(Vector2D newPosition, SDL_RendererFlip flip, double angle = 0.0f);

    int GetWidth() { return mWidth; }
    int GetHeight() { return mHeight; }
};

#endif
有帮助吗?

解决方案

I imagine your definition of Render looks like this

In .cpp

  void Texture2D::Render(Vector2D newPosition, SDL_RendererFlip flip, double angle = 0.0f)
  {
     ...
  }

When it should be

  void Texture2D::Render(Vector2D newPosition, SDL_RendererFlip flip, double angle )
  {
     ...
  }

You only supply the default value in the declaration ( normally .h )

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top