Well, explicit constructors are always safe, but can be inconvenient. explicitprovides a compilation error if you specify StrategyInterface*where expected Context. In doing so, it prevents the creation of a temporary Context. This becomes especially important in certain circumstances, for example:
Contexttakes responsibility for the pointer to StrategyInterfaceand removes it in the destructorContext / .- , , , (, a
Context a StrategyInterface* , StrategyInterface* s, StrategyInterface Context s?)
a Context StrategyInterface, , , std::string const char*. Context a StrategyInterface, .
(: - , - )