class CanBeTraded { public: virtual bool isTradable() = 0; };
class Car : public CanBeTraded { public: bool isTradable() { return true; // cars can be traded } };
void tradeItem(CanBeTraded* item) { if (item->isTradable()) { // Do some trade operations } }Example Brief: CanBeTraded interface can be used to determine whether an item can be traded or not. For example, in a game where players can trade items, weapons or armor can be marked as untradable to prevent them from being sold. This interface can be included in the game engine package library.