Use default parameters to achieve this. Something like:
void foo(int arg, int arg2 = 0, int arg3 = 0) {
...
}
which allows you to call foo
and pass either 1, 2 or 3 arguments to it.
Since you've mentioned your actual intentions: i.e. call "bossbattle(hades, biglion, biglion);
where inside bossbattle
it sets the classes passed in to temporary classes for battle".
In case this bossbattle
is constrained with the amount of (let's call it) battle participants (i.e. there will always be 1 to 3 participants), then you can use the aforementioned approach. Otherwise it might be more reasonable to define a class that extracts whatever "hades", "lion" and "tiger" have in common to define the base class, let's say class Creature
, and change the interface to take a container of creatures instead:
void bossbattle(const std::vector<Creature>& battleParticipants) {
...
}