How do design multiple endings?

In my game, the character kills the enemy with several items. Depending on the character’s behavior, the item may be lost or may remain until the game is over.

For example, I have four items, a, b, c, and d. If there is no ‘a’, the first ending is performed, and if there is no ‘b’, the second ending is performed.

My game has more items and many endings.

I’m going to make an ending system with c++.
Which method should I use?