Jessica Lingmn
Jessica Lingmn

Reputation: 1212

Can't draw objects in C++ graphics

In this code i want to show a circle, and a bar with black border color on a white background. But while i compile this code in TurboC++, this shows only a white background. can not understand why objects are not displaying.. what i'm missing?
Here's my code:

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

class Sun {
    public:
        Sun() {}

        void drawSun() {
            setcolor(0);
            circle(450, 260, 50);
        }
};

class Bar {
    private:
        Sun sn;

    public:
        drawBar() {
            sn.drawSun();
            setcolor(0);
            bar(100, 100, 200, 200);
        }
};

int main() {

    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "C:\\turboc3\\bgi");
    setbkcolor(15);

    Bar br;
    br.drawBar();

    getch();
    return 0;
}

Another Question: how to get this br object of Bar class in getimage() function? Thanks

Upvotes: 2

Views: 448

Answers (1)

Bhanu
Bhanu

Reputation: 1

Color no 0 and 15 are same use a different background color or different color for image. both 0 and 15 are for WHITE.

Upvotes: 0

Related Questions