Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program to illustrate the multi-level inheritance

Posted By: Easy Tutor     Category: C++ Programming     Views: 4937

A C++ Program to illustrate the multi-level inheritance.

Code for Program to illustrate the multi-level inheritance in C++ Programming

 #include<iostream.h>
 #include<graphics.h>
 #include<stdlib.h>
 #include<conio.h>
 #include<dos.h>

 /*************************************************************************///------------------------------  rect  ---------------------------------///*************************************************************************/class rect
    {
       public:
        void draw_rect(int,int,int,int,int);
    };

 /*************************************************************************///----------------------------  fill_rect  ------------------------------///*************************************************************************/class fill_rect:public rect
    {
       public:
        void draw_rect(int,int,int,int,int,int,int);
    };

 /*************************************************************************///---------------------------  animate_rect  ----------------------------///*************************************************************************/class animate_rect:public fill_rect
    {
       public:
        void draw_rect(int,int,int,int,int,int,int);
    };

 /*************************************************************************///----------------  draw_rect(int,int,int,int,int)  ---------------------///*************************************************************************/void rect::draw_rect(int x1,int y1,int x2,int y2,int boundry_color)
    {
       setcolor(boundry_color);
       rectangle(x1,y1,x2,y2);
    }


 /*************************************************************************///------------  draw_rect(int,int,int,int,int,int,int)  -----------------///*************************************************************************/void fill_rect::draw_rect(int x1,int y1,int x2,int y2,int boundry_color,
                        int pattern,int pattern_color)
    {
       rect::draw_rect(x1,y1,x2,y2,boundry_color);

       struct fillsettingstype t;

       getfillsettings(&t);

       setfillstyle(pattern,pattern_color);
       floodfill(x1+1,y1+1,boundry_color);
       setfillstyle(t.pattern,t.color);
    }


 /*************************************************************************///-------------  draw_rect(int,int,int,int,int,int,int)  ----------------///*************************************************************************/void animate_rect::draw_rect(int x1,int y1,int x2,int y2,int boundry_color,
                        int pattern,int pattern_color)
    {
       fill_rect::draw_rect(x1,y1,x2,y2,boundry_color,pattern,pattern_color);

       int size=imagesize(x1,y1,x2,y2);

       char *p;

       p=newchar[size];

       getimage(x1,y1,x2,y2,p);
       putimage(x1+100,y1+100,p,XOR_PUT);

       int x;
       int y;

       while(!kbhit())
      {
         x=random(getmaxx());
         y=y2+random(getmaxy());

         putimage(x,y,p,OR_PUT);
         delay(100);
         putimage(x,y,p,XOR_PUT);
      }
    }


 main()
    {
       clrscr();

       int graphic_driver=DETECT;
       int graphic_mode;
       int errorcode;

       initgraph(&graphic_driver,&graphic_mode,"..\\bgi");

       errorcode=graphresult();

       if(errorcode!=grOk)
      {
         restorecrtmode();
         cout<<"Graphic Error";
         exit(1);
      }

       rect x;

       x.draw_rect(20,20,150,150,4);

       fill_rect y;

       y.draw_rect(210,20,350,100,14,1,13);

       animate_rect z;

       z.draw_rect(400,20,530,100,14,7,10);

       getch();
       closegraph();
       return 0;
    }
  
Share: 


Didn't find what you were looking for? Find more on Program to illustrate the multi-level inheritance Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Program to illustrate the multi-level inheritance is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!