Q:

why does the derived class inherit the private members of the base class?

I know that the derived class can't access the private members of the base class, so why does the derived class inherit the private members of the base class? Is there any case that it is useful?
Thanks!

A:

The derived class needs the private members even though it can't access them directly. Otherwise it's behavior would not build on the class it is deriving from.
For example, pretend the private stuff is:
int i;

and the class has a geti() and seti(). The value of i has to be put somewhere, even if it is private,

A:

The public and protected methods of the base class can still access private variables of the base class, and these methods are available in the derived class.

A:

The base class can still use the private member variables & methods.
If you want the derived classes to have access to members but keep those members hidden from the outside world, make them protected:.
Here's an example to illustrate:
class Base
{
public:
  Base() : val(42.0f) {};
  float GetValue() const 
  {
    return val_;
  }
private:
  float val_;
};

class Derived : public Base
{
public:
  float ComputedValue() const
  {
    return GetValue() * 2.0f;
  } 
};

