#include <allegro.h>
void mouse();
class initialization
{
public:
void init()
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
install_timer();
install_keyboard();
install_mouse();
}
};
class base
{
public:
virtual void make_buffer() = 0;
virtual void make_sprite_to_buffer() = 0;
virtual void make_buffer_to_screen() = 0;
};
class back_g : public base
{
private:
BITMAP* back_ground;
BITMAP* buffer;
int x, y;
public:
back_g(int a, int B)/>
{
x = a;
y = b;
}
void make_buffer()
{
buffer = create_bitmap(640, 480);
}
void make_sprite_to_buffer()
{
back_ground = load_bitmap("res/background/back2.bmp", NULL);
blit(back_ground, buffer, 0, 0, x, y, 640, 480);
}
void make_buffer_to_screen()
{
blit(buffer, screen, 0, 0, x, y, 640, 480);
}
~back_g()
{
destroy_bitmap(back_ground);
destroy_bitmap(buffer);
}
};
int main()
{
initialization in;
back_g b(0, 15);
in.init();
readkey();
return 0;
}
END_OF_MAIN()
void mouse()
{
BITMAP* mouse_pointer = NULL;
mouse_pointer = load_bitmap("res/pointer.bmp", NULL);
set_mouse_sprite(mouse_pointer);
show_mouse(screen);
}
making object of derived class
Page 1 of 13 Replies - 387 Views - Last Post: 28 May 2011 - 04:43 PM
#1
making object of derived class
Posted 27 May 2011 - 10:43 PM
I cant make object of the derived class and the base class contains pure virtual functions...why is this so??
Replies To: making object of derived class
#2
Re: making object of derived class
Posted 28 May 2011 - 03:05 AM
Moved to C and C++. C++ Programmers forum is not for help, it's for discussion.
#3
Re: making object of derived class
Posted 28 May 2011 - 01:32 PM
Why do you need to use inheritance? I'm not familiar with allegro, but it might help if you posted whatever errors you're getting, or what you expect to happen and what actually happened if you were able to compile and run it.
#4
Re: making object of derived class
Posted 28 May 2011 - 04:43 PM
well im not exactly sure what your asking but you declared 3 pure virtual functions one lines 20-22 and it appears that you implemented those in your base class.
as vividexstance asked, why do you need to use inheritance? your base class is pointless unless you make another class the implements the pure virtual functions differently.
as vividexstance asked, why do you need to use inheritance? your base class is pointless unless you make another class the implements the pure virtual functions differently.
This post has been edited by ishkabible: 28 May 2011 - 05:14 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote









|