Should I make every static function that does not concern a member variable?

What is Design and Efficiency to create all static functions that do not affect a member variable of a class?

+3
source share
7 answers

In fact, you should consider creating non-static free functions as detailed in this question . This question is also very interesting.

In short, this question explains that you should prefer features other than friends whenever possible (which means they don't have access to non-public members).

+7
source

, - ?

: - , -, this, ; inlining, . , , "" - / this ; , .

: - -, . , object.fn(x, y, z) - - , .

, , , ; - , .

+3

- vs ?
- .

- vs -?
static member function this, non static member functions, .

0

, - , this. .

, , , ? , , . - , . , . , .

0

. - -. , static, , this ( ).

[: :

struct A {
  virtual void foo (int) = 0;
};

, foo(), static!:)]

0

, - - , (- virtual bool eatsPlants() ). , ++ .

0

. -, , , . ( -, , - . , ?) . (, , ), ; . , , ; , . ( , , , .)

0

All Articles