Why Inheritance is used in C++

In C++, if you have already made a class with many data members and member functions and now you want to re-use them in a new class, (without inheritance) you have to write each and every thing in that new class, but if we use the concept of inheritance, you can re-use the already made class in any other class.
Let me show you a practical example:
class animal
{
protected:
  int teeth,legs;
};
It is class animal, that have two data member teeth and legs. We declared teeth and legs because any animal class which will be inherit from this class would must have teeth or legs.
class dog : public animal
{
public:
 void bark()
 {
    teeth=32;
 }
void eat();
}
We inherited animal class in dog class means now class dog can use the data members of class animals. We declared bark function in dog because dog can bark. We can inherit as many classes from animal class. Like cat, lion,etc.