I've read that composition can be used instead of inheritance and all programs using inheritance can be transformed to a program using composition and vice-versa. I've also read that using composition is better than using inheritance.
Even though I've read the facts, I don't understand how and why this is true. I can't even think of an example to demonstrate this.
Could someone please help me clear out my doubts. It would be very much appreciated if you could use an example too.