hey guys ! i am new to graphics in c++ .. i have to develop an application called " paint " . i have to implement it using classes ( and inheritance in classes ) . For example i have to draw a line using mouse . All the graphic functions are implemented in the class Graphics.h file. my code is pasted and the exact problem lies below :
#include <iostream>
using namespace std;
class Point
{
protected :
int x1 ;
int y1 ;
public :
Point (int _x , int _y)
{
x1 = _x ;
y1 = _y ;
}
void SetX (int _x)
{
x1 = _x ;
}
void SetY (int _y)
{
y1 = _y ;
}
int GetX () const
{
return x1 ;
}
int GetY () const
{
return y1 ;
}
~Point()
{}
};
#include <iostream>
using namespace std;
#include "Point.h"
class Line : public Point
{
public :
Line (int x2= 0 , int y2=0) : Point (x1,y1)
{
}
~Line ()
{
}
};
#include <iostream>
using namespace std;
#include "circle.h"
#include "graphics.h"
#include "Point.h"
#include "Line.h"
void main ()
{
int maxx ;
int maxy ;
int x2 ;
int y2 ;
Line l ;
initwindow(450,300);
maxx = getmaxx();
maxy = getmaxy();
while (!ismouseclick(WM_LBUTTONDOWN))
{
Line(x2,y2);
}
getmouseclick(WM_LBUTTONDOWN,x2,y2);
system("pause");
}
ok the exact problem is in the " while loop " . because i have to draw a line and this function is implemented in the graphics.h file so should i call the constructor of class line in the while loop or the Line function of the graphics.h file ?? Remember i have to implement this assignment using classes .