What is wrong with making a unit test a friend of the class it is testing? [duplicate]

Ideally, you shouldn’t need to unit test private methods at all. All a consumer of your class should care about is the public interface, so that’s what you should test. If a private method has a bug, it should be caught by a unit test that invokes some public method on the class which eventually … Read more

Are inner classes in C++ automatically friends?

After having asked more or less the same question here myself, I wanted to share the (apparently) updated answer for C++11: Quoted from https://stackoverflow.com/a/14759027/1984137: standard $11.7.1 “A nested class is a member and as such has the same access rights as any other member. The members of an enclosing class have no special access to … Read more

public friend swap member function

There are several ways to write swap, some better than others. Over time, though, it was found a single definition works best. Let’s consider how we might think about writing a swap function. We first see that containers like std::vector<> have a single-argument member function swap, such as: struct vector { void swap(vector&) { /* … Read more

Why does C# not provide the C++ style ‘friend’ keyword? [closed]

On a side note. Using friend is not about violating the encapsulation, but on the contrary it’s about enforcing it. Like accessors+mutators, operators overloading, public inheritance, downcasting, etc., it’s often misused, but it does not mean the keyword has no, or worse, a bad purpose. See Konrad Rudolph’s message in the other thread, or if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)