J
JoeC
I am still working on my game and my program is getting better. Most
of what I want to works. I think I am having trouble with copy
constructor. Basically I want it to copy the gdata array. My gdata
will work if I do: gdata[32] = this->get(lp); But that is not what I
want to do I get some cryptic errors when I write the code like that is
commented out.
49 C:\Documents and Settings\Work\My Documents\C++\Dungeon
Adventure2\gaphic.cpp passing `const graphic' as `this' argument of
`BYTE graphic::get(int)' discards qualifiers
C:\Documents and Settings\Work\My Documents\C++\Dungeon
Adventure2\Makefile.win [Build Error] [gaphic.o] Error 1
I am pretty good with pointer and objects but my compiler is fustrating
me. Can I get some advice to make this copy constructer do what it is
suppoded to do.
class graphic{
int btmap;
int lr,ud; //Diminsion (size) of the graphic
BYTE gdata[32]; //bitmap array
HBITMAP hbitmap;
BITMAP bitmap;
HDC hdc, hdcmem;
void copy(BYTE in[]);
BYTE get(int n){return gdata[n];}
public:
graphic();
graphic(BYTE c[]);
graphic(const graphic&);
graphic& operator = (graphic&);
void SetGr(BYTE c[]);
void set(BYTE c[]);
void display(HWND, int, int);
};
graphic::graphic(const graphic& gr){
for(int lp = 0; lp != 32; lp++){
//gdata[32] = gr.get(lp); <- I get errors.
}
ud = lr = 16;
BITMAP bitmap = {0,ud,lr,2,1,1};
bitmap.bmBits = gdata;
hbitmap = CreateBitmapIndirect(&bitmap);
}
of what I want to works. I think I am having trouble with copy
constructor. Basically I want it to copy the gdata array. My gdata
will work if I do: gdata[32] = this->get(lp); But that is not what I
want to do I get some cryptic errors when I write the code like that is
commented out.
49 C:\Documents and Settings\Work\My Documents\C++\Dungeon
Adventure2\gaphic.cpp passing `const graphic' as `this' argument of
`BYTE graphic::get(int)' discards qualifiers
C:\Documents and Settings\Work\My Documents\C++\Dungeon
Adventure2\Makefile.win [Build Error] [gaphic.o] Error 1
I am pretty good with pointer and objects but my compiler is fustrating
me. Can I get some advice to make this copy constructer do what it is
suppoded to do.
class graphic{
int btmap;
int lr,ud; //Diminsion (size) of the graphic
BYTE gdata[32]; //bitmap array
HBITMAP hbitmap;
BITMAP bitmap;
HDC hdc, hdcmem;
void copy(BYTE in[]);
BYTE get(int n){return gdata[n];}
public:
graphic();
graphic(BYTE c[]);
graphic(const graphic&);
graphic& operator = (graphic&);
void SetGr(BYTE c[]);
void set(BYTE c[]);
void display(HWND, int, int);
};
graphic::graphic(const graphic& gr){
for(int lp = 0; lp != 32; lp++){
//gdata[32] = gr.get(lp); <- I get errors.
}
ud = lr = 16;
BITMAP bitmap = {0,ud,lr,2,1,1};
bitmap.bmBits = gdata;
hbitmap = CreateBitmapIndirect(&bitmap);
}