M
Manuel
The parent is an abstract class, with default implicit constructor:
-----------------------------------
class mhwidget
{
public:
virtual void draw()= 0;
virtual void setPosition(GLint, GLint)= 0;
virtual void setWidth(GLint)= 0;
virtual void setHeight(GLint)= 0;
virtual bool isMouseOver(GLint, GLint)= 0;
virtual ~mhwidget() {}
};
------------------------------------
The derived class I've written use a simple constructor, because the
parent have the default constructor. And without destructor. It's OK?
------------------------------------
class square : public mhwidget
{
private:
GLint positionX;
GLint positionY;
GLint width;
GLint height;
public:
square(int posX, int posY, GLint w, GLint h);
virtual void setPosition(GLint posX, GLint posX);
virtual void setWidth(GLint w);
virtual void setHeight(GLint h);
virtual bool isMouseOver(GLint posX, GLint posX);
virtual void draw();
};
------------------------------------
Besides, note that I use the same variables names in different functions
(posX and posY are in both constructor and setPosition, w and h are in
constructor, setWidth and setHeight. However they should be ok, because
they work loacally into the functions...it's ok too?
thanks,
Manuel
-----------------------------------
class mhwidget
{
public:
virtual void draw()= 0;
virtual void setPosition(GLint, GLint)= 0;
virtual void setWidth(GLint)= 0;
virtual void setHeight(GLint)= 0;
virtual bool isMouseOver(GLint, GLint)= 0;
virtual ~mhwidget() {}
};
------------------------------------
The derived class I've written use a simple constructor, because the
parent have the default constructor. And without destructor. It's OK?
------------------------------------
class square : public mhwidget
{
private:
GLint positionX;
GLint positionY;
GLint width;
GLint height;
public:
square(int posX, int posY, GLint w, GLint h);
virtual void setPosition(GLint posX, GLint posX);
virtual void setWidth(GLint w);
virtual void setHeight(GLint h);
virtual bool isMouseOver(GLint posX, GLint posX);
virtual void draw();
};
------------------------------------
Besides, note that I use the same variables names in different functions
(posX and posY are in both constructor and setPosition, w and h are in
constructor, setWidth and setHeight. However they should be ok, because
they work loacally into the functions...it's ok too?
thanks,
Manuel