Z
zaeminkr
I have a question about type conversion function for user defined
type.
I have two classes
class DRect
{
private :
double x0;
double y0;
double x1;
double y1;
public :
DRect(double a, double b, double c, double d) : x0(a), y0(b),
x1(c), y1(d) {}
void Union(DRect* p)
{
x0 = MIN(x0, p->x0);
y0 = MIN(y0, p->y0);
x1 = MAX(x1, p->x1);
y1 = MAX(y1, p->y1);
}
}
class IRect
{
private :
int x0;
int y0;
int x1;
int y1;
public :
IRect(int a, int b, int c, int d) : x0(a), y0(b), x1(c), y1(d) {}
}
And I want to do something like this.
{
DRect d(3.4, 2.6, 19.2, 93.2);
IRect i(10, 10, 100, 100);
d.Union(i);
// or
d.Union(&i)
}
Is it possible to make a such type conversion fuction -
IRect:perator DRect() or IRect:perator DRect*()?
Thanks in advance.
type.
I have two classes
class DRect
{
private :
double x0;
double y0;
double x1;
double y1;
public :
DRect(double a, double b, double c, double d) : x0(a), y0(b),
x1(c), y1(d) {}
void Union(DRect* p)
{
x0 = MIN(x0, p->x0);
y0 = MIN(y0, p->y0);
x1 = MAX(x1, p->x1);
y1 = MAX(y1, p->y1);
}
}
class IRect
{
private :
int x0;
int y0;
int x1;
int y1;
public :
IRect(int a, int b, int c, int d) : x0(a), y0(b), x1(c), y1(d) {}
}
And I want to do something like this.
{
DRect d(3.4, 2.6, 19.2, 93.2);
IRect i(10, 10, 100, 100);
d.Union(i);
// or
d.Union(&i)
}
Is it possible to make a such type conversion fuction -
IRect:perator DRect() or IRect:perator DRect*()?
Thanks in advance.