Decorator vs Inheritance

You have a Stream base class and need to support optional compression, encryption, and buffering in any combination. Using inheritance, how many classes would you need to cover all combinations of these three features?

A

9: 3 × 3 grid of feature combinations

B

3: one subclass per feature

C

6: one for each pair plus one for each single feature

D

8: one for each subset of {compression, encryption, buffering} including the empty set