I have two classes I cannot modify, both have exactly the same members:
class Pose1 {
public:
double x,y;
};
class Pose2 {
public:
double x,y;
};
One part of the code uses Pose1 the other one uses Pose2. Is there a way to implicit convert these into each other? Now I have to write all the time
Pose1 p1(0.5, 0.5);
Pose2 p2(p1.x,p2.y);
I know I can write a conversion function which just does that once. But I have a lot of different types with lots of arguments.
Is there any way I can do something like:
Pose2 p2 = static_cast<Pose2>(p1);
I cannot use member function because I cannot change this code.
Thank you!
Aucun commentaire:
Enregistrer un commentaire