i made a small code to debug and i get this error
player inherit from gameobject
code
///main
#include "game.h"
gameobject* pla;
int main()
{
std::vector<gameobject*> objects;
gameobject* pla = new player(32,32); -----> error is here
objects.push_back(pla);
cout<<objects[0]->numberID<<endl;
return 0;
}
/// gameobject
pragma once
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "game.h"
class gameobject
{
public:
virtual ~gameobject(){};
virtual void init()=0;
virtual void tick()=0;
virtual void render(SDL_Renderer* ren)=0;
virtual void destroy()=0;
virtual void setVelx(int velx)=0;
virtual void setVely(int vely)=0;
int numberID=0;
protected:
int width = pos.w;
int height = pos.h;
int posx = pos.x;
int posy = pos.y;
float velox;
float veloy;
SDL_Rect crop;
SDL_Rect pos;
SDL_Texture* tex;
////player.h
#pragma once
#include "gameobject.h"
class gameobject;
class player : public gameobject
{
public:
void init() override;
void tick() override;
void render(SDL_Renderer* ren) override;
// SDL_Renderer* renderer;
player(int pwidth,int pheight);
void destroy() override{
this->~player();
}
void setVelx(int velx) override;
void setVely(int vely) override;
int i = 0;
private:
~player() override;
};
/// player.cpp
#include "player.h"
player::player(int pwidth, int pheight)
{
this->pos.w = pwidth; //width
this->pos.h = pheight; // height
this->pos.x = 100; //posx
this->pos.y = 100; //posy
// cout<<"yes iam ren : "<<ren<<endl;
this->numberID = gameobject::numberID;
gameobject::numberID++;
//this->tex = IMG_LoadTexture(ren,"/home/younlok/Desktop/dash/res/pss.png");
this->tex = game::textures[0];
crop.x = 0;
crop.y = 0;
crop.w = 32;
crop.h = 32;
//game::hand->addObject(this);
}
void player::init()
{
}
void player::tick()
{
this->pos.x += this->velox;
this->pos.y += this->veloy;
}
void player::render(SDL_Renderer* ren)
{
SDL_RenderCopy(ren,tex,&crop,&pos);
}
void player::setVelx(int velx)
{
this->velox = velx;
}
void player::setVely(int vely)
{
this->veloy = vely;
}
player::~player(){}