I have two different structs which I want to convert to each other like this:
PointI a = PointI(3,5);
PointF b = a;
I assume that I will need to do something like the code below:
struct PointF
{
PointF operator=(PointI point){
x = point.x;
y = point.y;
return *this;
}
float x, y;
};
struct PointI
{
PointI operator=(PointF point)
{
x = point.x;
y = point.y;
return *this;
}
int x, y;
};
But the problem is that PointF
uses PointI
before it is declared. From what I've read in other questions, I understand that I can declare PointI
before defining both structs, and then use a pointer. Though it seems that I won't be able to access the variables x
and y
from that pointer, as these are not defined yet.
Is there a way I can add these variables to the struct declaration before defining them? Or is there a better way to solve this problem?