I want to allow my Class1 to be convertible to Class2 by a type conversion operator:
class Class1 {
public:
operator Class2() const {
//....
}
}
But if I create a Class2 object in the operator implementation, very likely it will not get deleted by the caller. So what is the best way to implement such a feature?
There only needs to be deletion if you do something crazy like this:
However, the following is fine: