Hey guys I just learned how to work with header files but I have a simple error .
I suggest you guys dont look at gameboard.cpp because it just runs fine with ubuntu and no errors with it.
my problem is when I run the main it gives the eroor undifined reference to gameboards::gameboards();
what is the problem . I check the internet and I think it must be working fine
mohre.h :
#ifndef __MOHRE_H
#define __MOHRE_H
struct mohre
{
int color;
};
#endif
gameboard.h :
#include "mohre.h"
class gameboards
{
public :
mohre ***gb;
int timer1,timer2;
int moverx,movery;
int goadd;
void moverdown();
void movertop();
void moverright();
void moverleft();
void preadd();
void add();
void mohreswitch(int x,int y);
gameboards();
};
gameboard.cpp :
#include <cstdlib>
#include <time.h>
#include "gameboard.h"
#include "mohre.h"
using namespace std;
mohre* goingadd[6];
gameboards::gameboards()
{
moverx=0;
movery=0;
timer1=0;
timer2=0;
gb = new mohre **[6];
for (int i=0;i<6;i++)
{
gb[i] = new mohre *[20];
}
for (int i=0;i<6;i++)
for (int j=0;j<20;j++)
gb[i][j]=0;
}
void gameboards::mohreswitch(int x,int y)
{
mohre *ali;
ali = gb[x][y];
gb[x][y] = gb[x+1][y];
gb[x+1][y] = ali;
}
void gameboards::preadd()
{
srand(time(0));
for (int i=0;i<6;i++)
{
goingadd[i] = new mohre();
goingadd[i]->color = rand()%5;
}
}
void gameboards::moverright()
{
if (moverx<=9)
moverx++;
}
void gameboards::movertop()
{
if(movery<=10)
movery++;
}
void gameboards::moverdown()
{
if(movery>=1)
movery--;
}
void gameboards::moverleft()
{
if(moverx>=1)
moverx--;
}
and the main :
#include <iostream>
#include "gameboard.h"
#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>
#include <string>
using namespace std;
int main()
{
gameboards hieee;
return 0;
}