Skip to content

Instantly share code, notes, and snippets.

@mrmikejones
Last active November 6, 2020 15:47
Show Gist options
  • Save mrmikejones/4ff1790a971df4f3856864de8ab49470 to your computer and use it in GitHub Desktop.
Save mrmikejones/4ff1790a971df4f3856864de8ab49470 to your computer and use it in GitHub Desktop.
struct Vector3_A {
float x;
float y;
float z;
};
class Vector3_B {
Vector3_B(float x, float y, float x);
float getX();
float getY();
float getZ();
private:
float m_coords[3];
};
class MyVectorWrapper : public Vector3_B {
public:
explicit MyVectorWrapper(const Vector3_A &inVal)
: Vector3_B(inVal.x, inVal.y, inVal.z)
{}
explicit operator Vector3_A() {
return Vector3_A { getX(), getY(), getZ() };
}
};
void foo() {
Vector3_A aVector;
MyVectorWrapper myVector(aVector);
// ...
Vector3_B bVector(myVector);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment