Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shall I make every function static, which do not touch the member variable?

Tags:

c++

static

What is the Design and Performance impact for making all functions static which do not touch the member variable of the class?

like image 237
Satbir Avatar asked May 26 '11 07:05

Satbir


1 Answers

You should actually consider making them non-static free functions, as explained in detail in this question. This question is also very interesting.

In a nutshell, these question explain that you should prefer non-friend non-member functions whenever possible (meaning when they do not access non-public members).

like image 174
Björn Pollex Avatar answered Sep 27 '22 23:09

Björn Pollex