1)How do I copy a struct of one type to a struct of another type using a conversion function?
2) Is there a faster way to set the variables in a struct then typing out each one?
Explanation:
How do I convert one struct type to another using my own function?
Basically I want to be able to do the following:
fVertex3d;
fVertex3d.x = 1.5;
fVertex3d.y= 14.1'
fVertex3d.z = 11.4;
iVertex3d = fVertex3d;
Then iVertex3d sshould contain (2,14,11).
Would operator overloading be required for this?
I just don't want to have to type this over and over:
fVertex3d pos1;
pos1.x = 1.5;
pos1.y= 14.1'
pos1.z = 11.4;
iVertex3d pos2;
pos2.x = align(pos1.x);
pos2.y = align(pos1.y);
pos2.z = align(pos1.z)
Also it is required that I use my own align function.
About the struct varaibles, is there a faster way to set them then having to type .x,.y,.z ?
Structs and convert function:
//Structs
struct iVertex3d
{
int x,y,z;
};
struct fVertex3d
{
float x,y,z;
};
//Functions
signed int align(float f)
{
return static_cast<signed int>((f < 0) ? floor(f) : f);
}