On Wed, Oct 15, 2003 at 01:52:31PM +0200, Lars Gullik Bjønnes wrote: > Free functions should ideally not access class variables,
This assumes that the class is not a random collection of individual thing - which it is in our case - but "something real". > the functions should be free only when they don't need access to the > class variables and only need the class's public interface for > implementation. (and then of course no class variables should be > public.) > This is the encapsulation part. (or course this can be simulated with > anon namespaces, but then the design is more "open" and access to the > variables are not as controlled.) Handing out non-const refs to members is completely destroying the type of encapsulation you speak of here ("access"). The two things are functionality-wise completely equivalent. But: In the class solution you have to show private members like 'last_files_' in the .h, whereas in the namespace solution they are hidden in the .C. So this is better encapsulation of the "visibility" type. > So, I guess, all in all I am more in favor of class variables than > variables in a anon namespace. Which is a bit of a surprise to me. We have a draw when it comes to encapsulating access and a point for namespaces when it comes to not exposing implementation details. Well. So let's stay with the class as it is. I am not religious about this bit. Andre'