Effective C++ Item 23 Prefer non-member non-friend functions to member functions

后端 未结 7 1943
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 03:09

While puzzling with some facts on class design, specifically whether the functions should be members or not, I looked into Effective c++ and found Item 23, namely, Prefer no

7条回答
  •  清酒与你
    2020-11-27 03:28

    I think sort is not implemented as a member function because it's widely used, not only for vectors. If they had it as a member function, they'd have to re-implement it each time for each container using it. So I think it's for easier implementation.

提交回复
热议问题