What is Design and Efficiency to create all static functions that do not affect a member variable of a class?
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).
, - ?
: - , -, this, ; inlining, . , , "" - / this ; , .
this
: - -, . , object.fn(x, y, z) - - , .
object.fn(x, y, z)
, , , ; - , .
- vs ?- .
- vs -?static member function this, non static member functions, .
static member function
non static member functions
, - , this. .
, , , ? , , . - , . , . , .
. - -. , static, , this ( ).
static
[: :
struct A { virtual void foo (int) = 0; };
, foo(), static!:)]
foo()
, - - , (- virtual bool eatsPlants() ). , ++ .
virtual bool eatsPlants()
. -, , , . ( -, , - . , ?) . (, , ), ; . , , ; , . ( , , , .)