This is my main class:
class Human{
public:
Human(IHat *hat){
hat->ChooseHat();
}
};
Here is classes that are about hats:
class IHat{
public:
virtual void ChooseHat() = 0;
};
class PirateHat : public IHat{
public:
void ChooseHat() override{
std::cout << "Tamagochi has pirate hat" << std::endl;
}
};
class Beret : public IHat{
public:
void ChooseHat() override{
std::cout << "Tamagochi has beret" << std::endl;
}
};
I use ioc container from boost::di :
auto set1 = boost::di::make_injector(
boost::di::bind<IHat>().to<PirateHat>(),
);
auto human = set1.create<Human>();
Can I create appropriate ioc container with boost::di but for function ChooseClothes not for constructor. For example:
class Human{
public:
void ChooseClothes(IHat *hat){
hat->ChooseHat();
}
};