@class vs. #import

后端 未结 16 1409
渐次进展
渐次进展 2020-11-21 22:42

It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header t

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-21 23:26

    When I develop, I have only three things in mind that never cause me any problems.

    1. Import super classes
    2. Import parent classes (when you have children and parents)
    3. Import classes outside your project (like in frameworks and libraries)

    For all other classes (subclasses and child classes in my project self), I declare them via forward-class.

提交回复
热议问题