From: "Scott Tsai" Newsgroups: comp.os.msdos.djgpp Subject: Problem with C++ & Allegro Date: 1 Feb 1999 19:29:10 GMT Organization: SEEDNet News Service Lines: 69 Message-ID: <01be4e19$14d058a0$d1c4af8b@scotttsa> NNTP-Posting-Host: t196-209.dialup.seed.net.tw X-Newsreader: Microsoft Internet News 4.70.1155 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I'm trying to write a very simple class (called Picture)that uses the Allegro library to display bitmaps. when I use Picture pic1 = filename[1]; Picture pic2 = filename[2]; . . while(1) { pic1.show(); pic2.show(); } it's always okay. but when I do Picture pics[5]; or Picture *pics = new Picture[5]; then do int i = 0; while(...) { i%=5; pics[i].show(); i++; } After I call Picture::Picture(char*) the BITMAP *pic in all the Picture objects (pic[1], pic[2] ....) are always pointed to the same address(the last picture I load), only the PALLETE pic_pallete in each object differs, why? here's my code: class Picture { private: BITMAP* pic; PALLETE pic_pallete; public: Picture() {} //I don't know how to write a default constructor //for the class Picture(char* filename) { pic = load_bitmap(filename, pic_pallete); } ~Picture() { destroy_bitmap(pic); } void show(void) { set_pallete(pic_pallete); blit(pic, screen, 0, 0, (SCREEN_W - pic->w)/2, (SCREEN_H - pic->h)/2, pic->w, pic->h); } }; I guess this is a because I didn't learn C++ well enough.....