Member function vs. nonmember function?

后端 未结 2 1448
孤街浪徒
孤街浪徒 2021-02-15 10:34

What is your rule for which functions that operate on a class should be member functions vs. nonmember functions? For example, I have a class which represents a maze using a mat

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-15 11:17

    Herb Sutter says "we want to make them nonmember nonfriends if reasonably possible", and he's smarter than I am.

    http://www.gotw.ca/gotw/084.htm

提交回复
热议问题