Is it possible to write auto-cast operator outside a struct?

前端 未结 4 1086
星月不相逢
星月不相逢 2021-02-05 02:53

The exact situation is next: I have defined in system API structs CGPoint and CGSize, and I want to be able to write my_point = my_size. I

4条回答
  •  感情败类
    2021-02-05 03:22

    If you can derive from or wrap CGPoint and use the new class instead throughout your code, then you can provide whatever operators you like. The new class can have a conversion operator to CGPoint facilitating interaction with existing functions.

提交回复
热议问题