I'd like to know if there's any possibility to create a constructor in C++ which uses for example float but this float isn't necessary. I mean:
Constructor:
Fruit::Fruit(float weight)
{
weight = 1;
this->setWeight(weight);
}
I need to do something like that using one constructor:
Fruit pear = Fruit(5); - gives a pear with weight 5
Fruit strawberry = Fruit(); - gives a strawberry with default weight 1